implements the get_tasks

This commit is contained in:
Tamo 2022-09-22 20:02:55 +02:00 committed by Clément Renault
parent 5b282acb7b
commit f84cbee170
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
7 changed files with 131 additions and 22 deletions

View file

@ -31,6 +31,7 @@ pub struct Query {
#[serde(rename = "type")]
pub kind: Option<Vec<Kind>>,
pub index_uid: Option<Vec<String>>,
pub uid: Option<Vec<TaskId>>,
}
impl Default for Query {
@ -41,6 +42,7 @@ impl Default for Query {
status: None,
kind: None,
index_uid: None,
uid: None,
}
}
}
@ -72,6 +74,15 @@ impl Query {
..self
}
}
pub fn with_uid(self, uid: TaskId) -> Self {
let mut task_vec = self.uid.unwrap_or_default();
task_vec.push(uid);
Self {
uid: Some(task_vec),
..self
}
}
}
pub mod db_name {
@ -172,7 +183,11 @@ impl IndexScheduler {
};
// This is the list of all the tasks.
let mut tasks = RoaringBitmap::from_iter(0..last_task_id);
let mut tasks = RoaringBitmap::from_sorted_iter(0..last_task_id).unwrap();
if let Some(uids) = query.uid {
tasks &= RoaringBitmap::from_iter(uids);
}
if let Some(status) = query.status {
let mut status_tasks = RoaringBitmap::new();
@ -256,6 +271,10 @@ impl IndexScheduler {
Ok(self.file_store.new_update()?)
}
pub fn delete_update_file(&self, uuid: Uuid) -> Result<()> {
Ok(self.file_store.delete(uuid)?)
}
/// This worker function must be run in a different thread and must be run only once.
pub fn run(&self) -> ! {
loop {