fix double entries
This commit is contained in:
parent
50c76560c0
commit
74ec396296
1 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
mod project;
|
||||
|
@ -45,6 +47,19 @@ where
|
|||
ret
|
||||
}
|
||||
|
||||
fn unique_tasks(tasks: Vec<Task>) -> Vec<Task> {
|
||||
let mut seen_ids = HashSet::new();
|
||||
let mut unique_tasks = Vec::with_capacity(tasks.len());
|
||||
|
||||
for task in tasks {
|
||||
if seen_ids.insert(task.id) {
|
||||
unique_tasks.push(task);
|
||||
}
|
||||
}
|
||||
|
||||
unique_tasks
|
||||
}
|
||||
|
||||
pub struct ProjectID(pub isize);
|
||||
|
||||
impl ProjectID {
|
||||
|
@ -146,7 +161,7 @@ impl VikunjaAPI {
|
|||
|
||||
// tasks
|
||||
pub fn get_all_tasks(&self) -> Vec<Task> {
|
||||
get_all_items(|x| self.get_task_page(x))
|
||||
unique_tasks(get_all_items(|x| self.get_task_page(x)))
|
||||
}
|
||||
|
||||
pub fn get_task(&self, id: isize) -> Task {
|
||||
|
|
Loading…
Reference in a new issue