Centralize API for working set to a single struct
Rather than allow addressing tasks either by working set ID or uuid, with attendant performance issues, this moves the API for the working set to a single struct that just serves as a 1-1 mapping of indexes to UUIDs. It's up to the caller to use this information.
This commit is contained in:
@@ -33,7 +33,11 @@ mod test {
|
||||
execute(&mut w, &mut replica, modification).unwrap();
|
||||
|
||||
// check that the task appeared..
|
||||
let task = replica.get_working_set_task(1).unwrap().unwrap();
|
||||
let working_set = replica.working_set().unwrap();
|
||||
let task = replica
|
||||
.get_task(working_set.by_index(1).unwrap())
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(task.get_description(), "my description");
|
||||
assert_eq!(task.get_status(), Status::Pending);
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ pub(crate) fn execute<W: WriteColor>(
|
||||
filter: Filter,
|
||||
debug: bool,
|
||||
) -> Fallible<()> {
|
||||
let working_set = replica.working_set()?;
|
||||
|
||||
for task in filtered_tasks(replica, &filter)? {
|
||||
let uuid = task.get_uuid();
|
||||
|
||||
@@ -24,7 +26,7 @@ pub(crate) fn execute<W: WriteColor>(
|
||||
}
|
||||
} else {
|
||||
t.add_row(row![b->"Uuid", uuid]);
|
||||
if let Some(i) = replica.get_working_set_index(uuid)? {
|
||||
if let Some(i) = working_set.by_uuid(uuid) {
|
||||
t.add_row(row![b->"Id", i]);
|
||||
}
|
||||
t.add_row(row![b->"Description", task.get_description()]);
|
||||
|
||||
Reference in New Issue
Block a user