Iterate values rather than sending multiple get requests

This commit is contained in:
mdecimus
2024-03-05 10:35:16 +01:00
parent ff279b3a39
commit 48f255b31f
18 changed files with 260 additions and 212 deletions

View File

@@ -56,7 +56,6 @@ pub async fn test(db: Store) {
BatchBuilder::new()
.with_account_id(0)
.with_collection(0)
.with_account_id(0)
.update_document(0)
.set(ValueClass::Property(1), value.as_slice())
.set(ValueClass::Property(0), "check1")
@@ -86,7 +85,6 @@ pub async fn test(db: Store) {
BatchBuilder::new()
.with_account_id(0)
.with_collection(0)
.with_account_id(0)
.update_document(0)
.clear(ValueClass::Property(1))
.build_batch(),

View File

@@ -459,26 +459,21 @@ pub async fn test_filter(db: Store, fts: FtsStore) {
.await
.unwrap();
assert_eq!(
db.get_values::<String>(
sorted_docset
.ids
.into_iter()
.map(|document_id| ValueKey {
account_id: 0,
collection: COLLECTION_ID,
document_id: document_id as u32,
class: ValueClass::Property(fields_u8["accession_number"])
})
.collect()
)
.await
.unwrap()
.into_iter()
.flatten()
.collect::<Vec<_>>(),
expected_results
);
let mut results = Vec::new();
for document_id in sorted_docset.ids {
results.push(
db.get_value::<String>(ValueKey {
account_id: 0,
collection: COLLECTION_ID,
document_id: document_id as u32,
class: ValueClass::Property(fields_u8["accession_number"]),
})
.await
.unwrap()
.unwrap(),
);
}
assert_eq!(results, expected_results);
}
}
@@ -554,25 +549,20 @@ pub async fn test_sort(db: Store) {
.await
.unwrap();
assert_eq!(
db.get_values::<String>(
sorted_docset
.ids
.into_iter()
.map(|document_id| ValueKey {
account_id: 0,
collection: COLLECTION_ID,
document_id: document_id as u32,
class: ValueClass::Property(fields["accession_number"])
})
.collect()
)
.await
.unwrap()
.into_iter()
.flatten()
.collect::<Vec<_>>(),
expected_results
);
let mut results = Vec::new();
for document_id in sorted_docset.ids {
results.push(
db.get_value::<String>(ValueKey {
account_id: 0,
collection: COLLECTION_ID,
document_id: document_id as u32,
class: ValueClass::Property(fields["accession_number"]),
})
.await
.unwrap()
.unwrap(),
);
}
assert_eq!(results, expected_results);
}
}