Skip to content

Commit 26d9289

Browse files
committed
Rename uid, status and types filters to plural
1 parent afa8d17 commit 26d9289

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

src/indexes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ impl Index {
903903
/// ```
904904
pub async fn get_tasks(&self) -> Result<TasksResults, Error> {
905905
let mut query = TasksQuery::new(&self.client);
906-
query.with_index_uid([self.uid.as_str()]);
906+
query.with_index_uids([self.uid.as_str()]);
907907

908908
self.client.get_tasks_with(&query).await
909909
}
@@ -924,7 +924,7 @@ impl Index {
924924
/// # let index = client.create_index("get_tasks_with", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap().try_make_index(&client).unwrap();
925925
///
926926
/// let mut query = TasksQuery::new(&client);
927-
/// query.with_index_uid(["none_existant"]);
927+
/// query.with_index_uids(["none_existant"]);
928928
/// let tasks = index.get_tasks_with(&query).await.unwrap();
929929
///
930930
/// assert!(tasks.results.len() > 0);
@@ -936,7 +936,7 @@ impl Index {
936936
tasks_query: &TasksQuery<'_>,
937937
) -> Result<TasksResults, Error> {
938938
let mut query = tasks_query.clone();
939-
query.with_index_uid([self.uid.as_str()]);
939+
query.with_index_uids([self.uid.as_str()]);
940940

941941
self.client.get_tasks_with(&query).await
942942
}

src/tasks.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,16 @@ pub struct TasksQuery<'a> {
406406
pub client: &'a Client,
407407
// Index uids array to only retrieve the tasks of the indexes.
408408
#[serde(skip_serializing_if = "Option::is_none")]
409-
pub index_uid: Option<Vec<&'a str>>,
409+
pub index_uids: Option<Vec<&'a str>>,
410410
// Statuses array to only retrieve the tasks with these statuses.
411411
#[serde(skip_serializing_if = "Option::is_none")]
412-
pub status: Option<Vec<&'a str>>,
412+
pub statuses: Option<Vec<&'a str>>,
413413
// Types array to only retrieve the tasks with these [TaskType].
414-
#[serde(skip_serializing_if = "Option::is_none", rename = "type")]
415-
pub task_type: Option<Vec<&'a str>>,
414+
#[serde(skip_serializing_if = "Option::is_none", rename = "types")]
415+
pub task_types: Option<Vec<&'a str>>,
416416
// Uids of the tasks to retrieve
417417
#[serde(skip_serializing_if = "Option::is_none")]
418-
pub uid: Option<Vec<&'a u32>>,
418+
pub uids: Option<Vec<&'a u32>>,
419419
// Date to retrieve all tasks that were enqueued before it.
420420
#[serde(
421421
skip_serializing_if = "Option::is_none",
@@ -465,12 +465,12 @@ impl<'a> TasksQuery<'a> {
465465
pub fn new(client: &'a Client) -> TasksQuery<'a> {
466466
TasksQuery {
467467
client,
468-
index_uid: None,
469-
status: None,
470-
task_type: None,
468+
index_uids: None,
469+
statuses: None,
470+
task_types: None,
471471
limit: None,
472472
from: None,
473-
uid: None,
473+
uids: None,
474474
before_enqueued_at: None,
475475
after_enqueued_at: None,
476476
before_started_at: None,
@@ -479,32 +479,32 @@ impl<'a> TasksQuery<'a> {
479479
after_finished_at: None,
480480
}
481481
}
482-
pub fn with_index_uid<'b>(
482+
pub fn with_index_uids<'b>(
483483
&'b mut self,
484-
index_uid: impl IntoIterator<Item = &'a str>,
484+
index_uids: impl IntoIterator<Item = &'a str>,
485485
) -> &'b mut TasksQuery<'a> {
486-
self.index_uid = Some(index_uid.into_iter().collect());
486+
self.index_uids = Some(index_uids.into_iter().collect());
487487
self
488488
}
489-
pub fn with_status<'b>(
489+
pub fn with_statuses<'b>(
490490
&'b mut self,
491-
status: impl IntoIterator<Item = &'a str>,
491+
statuses: impl IntoIterator<Item = &'a str>,
492492
) -> &'b mut TasksQuery<'a> {
493-
self.status = Some(status.into_iter().collect());
493+
self.statuses = Some(statuses.into_iter().collect());
494494
self
495495
}
496-
pub fn with_type<'b>(
496+
pub fn with_types<'b>(
497497
&'b mut self,
498-
task_type: impl IntoIterator<Item = &'a str>,
498+
task_types: impl IntoIterator<Item = &'a str>,
499499
) -> &'b mut TasksQuery<'a> {
500-
self.task_type = Some(task_type.into_iter().collect());
500+
self.task_types = Some(task_types.into_iter().collect());
501501
self
502502
}
503-
pub fn with_uid<'b>(
503+
pub fn with_uids<'b>(
504504
&'b mut self,
505-
index_uid: impl IntoIterator<Item = &'a u32>,
505+
uids: impl IntoIterator<Item = &'a u32>,
506506
) -> &'b mut TasksQuery<'a> {
507-
self.uid = Some(index_uid.into_iter().collect());
507+
self.uids = Some(uids.into_iter().collect());
508508
self
509509
}
510510
pub fn with_before_enqueued_at<'b>(
@@ -735,18 +735,18 @@ mod test {
735735
let mock_server_url = &mockito::server_url();
736736
let client = Client::new(mock_server_url, "masterKey");
737737
let path =
738-
"/tasks?indexUid=movies,test&status=equeued&type=documentDeletion&uid=1&limit=0&from=1";
738+
"/tasks?indexUids=movies,test&statuses=equeued&types=documentDeletion&uids=1&limit=0&from=1";
739739

740740
let mock_res = mock("GET", path).with_status(200).create();
741741

742742
let mut query = TasksQuery::new(&client);
743743
query
744-
.with_index_uid(["movies", "test"])
745-
.with_status(["equeued"])
746-
.with_type(["documentDeletion"])
744+
.with_index_uids(["movies", "test"])
745+
.with_statuses(["equeued"])
746+
.with_types(["documentDeletion"])
747747
.with_from(1)
748748
.with_limit(0)
749-
.with_uid([&1]);
749+
.with_uids([&1]);
750750

751751
let _ = client.get_tasks_with(&query).await;
752752

@@ -821,15 +821,15 @@ mod test {
821821
async fn test_get_tasks_on_struct_with_params() -> Result<(), Error> {
822822
let mock_server_url = &mockito::server_url();
823823
let client = Client::new(mock_server_url, "masterKey");
824-
let path = "/tasks?indexUid=movies,test&status=equeued&type=documentDeletion";
824+
let path = "/tasks?indexUids=movies,test&statuses=equeued&types=documentDeletion";
825825

826826
let mock_res = mock("GET", path).with_status(200).create();
827827

828828
let mut query = TasksQuery::new(&client);
829829
let _ = query
830-
.with_index_uid(["movies", "test"])
831-
.with_status(["equeued"])
832-
.with_type(["documentDeletion"])
830+
.with_index_uids(["movies", "test"])
831+
.with_statuses(["equeued"])
832+
.with_types(["documentDeletion"])
833833
.execute()
834834
.await;
835835

@@ -839,9 +839,9 @@ mod test {
839839
}
840840

841841
#[meilisearch_test]
842-
async fn test_get_tasks_with_none_existant_index_uid(client: Client) -> Result<(), Error> {
842+
async fn test_get_tasks_with_none_existant_index_uids(client: Client) -> Result<(), Error> {
843843
let mut query = TasksQuery::new(&client);
844-
query.with_index_uid(["no_name"]);
844+
query.with_index_uids(["no_name"]);
845845
let tasks = client.get_tasks_with(&query).await.unwrap();
846846

847847
assert_eq!(tasks.results.len(), 0);
@@ -851,7 +851,7 @@ mod test {
851851
#[meilisearch_test]
852852
async fn test_get_tasks_with_execute(client: Client) -> Result<(), Error> {
853853
let tasks = TasksQuery::new(&client)
854-
.with_index_uid(["no_name"])
854+
.with_index_uids(["no_name"])
855855
.execute()
856856
.await
857857
.unwrap();

0 commit comments

Comments
 (0)