mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-13 00:06:24 +00:00
make Task index_uid an option
Not all task relate to an index. Tasks that don't have an index_uid set to None
This commit is contained in:
@ -109,7 +109,8 @@ impl Store {
|
||||
pub fn put(&self, txn: &mut RwTxn, task: &Task) -> Result<()> {
|
||||
self.tasks.put(txn, &BEU64::new(task.id), task)?;
|
||||
self.uids_task_ids
|
||||
.put(txn, &(&task.index_uid, task.id), &())?;
|
||||
// TODO(marin): The index uid should be remaped to a task queue identifier here
|
||||
.put(txn, &(&task.index_uid.as_ref().unwrap(), task.id), &())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -325,7 +326,7 @@ pub mod test {
|
||||
let tasks = (0..100)
|
||||
.map(|_| Task {
|
||||
id: rand::random(),
|
||||
index_uid: IndexUid::new_unchecked("test"),
|
||||
index_uid: Some(IndexUid::new_unchecked("test")),
|
||||
content: TaskContent::IndexDeletion,
|
||||
events: vec![],
|
||||
})
|
||||
@ -356,14 +357,14 @@ pub mod test {
|
||||
|
||||
let task_1 = Task {
|
||||
id: 1,
|
||||
index_uid: IndexUid::new_unchecked("test"),
|
||||
index_uid: Some(IndexUid::new_unchecked("test")),
|
||||
content: TaskContent::IndexDeletion,
|
||||
events: vec![],
|
||||
};
|
||||
|
||||
let task_2 = Task {
|
||||
id: 0,
|
||||
index_uid: IndexUid::new_unchecked("test1"),
|
||||
index_uid: Some(IndexUid::new_unchecked("test1")),
|
||||
content: TaskContent::IndexDeletion,
|
||||
events: vec![],
|
||||
};
|
||||
@ -379,18 +380,28 @@ pub mod test {
|
||||
|
||||
txn.abort().unwrap();
|
||||
assert_eq!(tasks.len(), 1);
|
||||
assert_eq!(&*tasks.first().unwrap().index_uid, "test");
|
||||
assert_eq!(
|
||||
tasks
|
||||
.first()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.index_uid
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.as_str(),
|
||||
"test"
|
||||
);
|
||||
|
||||
// same thing but invert the ids
|
||||
let task_1 = Task {
|
||||
id: 0,
|
||||
index_uid: IndexUid::new_unchecked("test"),
|
||||
index_uid: Some(IndexUid::new_unchecked("test")),
|
||||
content: TaskContent::IndexDeletion,
|
||||
events: vec![],
|
||||
};
|
||||
let task_2 = Task {
|
||||
id: 1,
|
||||
index_uid: IndexUid::new_unchecked("test1"),
|
||||
index_uid: Some(IndexUid::new_unchecked("test1")),
|
||||
content: TaskContent::IndexDeletion,
|
||||
events: vec![],
|
||||
};
|
||||
@ -405,7 +416,17 @@ pub mod test {
|
||||
let tasks = store.list_tasks(&txn, None, Some(filter), None).unwrap();
|
||||
|
||||
assert_eq!(tasks.len(), 1);
|
||||
assert_eq!(&*tasks.first().unwrap().index_uid, "test");
|
||||
assert_eq!(
|
||||
&*tasks
|
||||
.first()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.index_uid
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.as_str(),
|
||||
"test"
|
||||
);
|
||||
}
|
||||
|
||||
proptest! {
|
||||
|
Reference in New Issue
Block a user