mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 08:41:00 +00:00
Add a helper method for getting the latest batch
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
This commit is contained in:
@ -1309,7 +1309,7 @@ async fn test_summarized_dump_creation() {
|
||||
let server = Server::new_shared();
|
||||
let (task, _status_code) = server.create_dump().await;
|
||||
server.wait_task(task.uid()).await.succeeded();
|
||||
let (batch, _) = server.get_batch(task.uid() as u32).await;
|
||||
let (batch, _) = server.get_latest_batch().await;
|
||||
assert_json_snapshot!(batch,
|
||||
{
|
||||
".uid" => "[uid]",
|
||||
|
@ -429,6 +429,19 @@ impl<State> Server<State> {
|
||||
self.service.get(url).await
|
||||
}
|
||||
|
||||
// https://www.meilisearch.com/docs/reference/api/batches#get-batches states:
|
||||
// "Batches are always returned in descending order of uid. This means that by default,
|
||||
// the most recently created batch objects appear first."
|
||||
pub async fn get_latest_batch(&self) -> (Option<Value>, StatusCode) {
|
||||
let url = "/batches?limit=1&offset=0";
|
||||
let (value, code) = self.service.get(url).await;
|
||||
value
|
||||
.get("results")
|
||||
.and_then(|results| results.as_array())
|
||||
.and_then(|array| array.first())
|
||||
.map_or((None, code), |latest| (Some(Value(latest.clone())), code))
|
||||
}
|
||||
|
||||
pub async fn get_features(&self) -> (Value, StatusCode) {
|
||||
self.service.get("/experimental-features").await
|
||||
}
|
||||
|
Reference in New Issue
Block a user