Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing startedAt field in EnqueuedTask #485

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ mod tests {
} => assert_eq!(index_uid, *index.uid),
Task::Processing {
content:
EnqueuedTask {
ProcessingTask {
index_uid: Some(index_uid),
..
},
Expand Down
34 changes: 30 additions & 4 deletions src/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,25 @@ impl AsRef<u32> for EnqueuedTask {
}
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProcessingTask {
#[serde(with = "time::serde::rfc3339")]
pub enqueued_at: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub started_at: OffsetDateTime,
pub index_uid: Option<String>,
#[serde(flatten)]
pub update_type: TaskType,
pub uid: u32,
}

impl AsRef<u32> for ProcessingTask {
fn as_ref(&self) -> &u32 {
&self.uid
}
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase", tag = "status")]
pub enum Task {
Expand All @@ -190,7 +209,7 @@ pub enum Task {
},
Processing {
#[serde(flatten)]
content: EnqueuedTask,
content: ProcessingTask,
},
Failed {
#[serde(flatten)]
Expand All @@ -205,7 +224,8 @@ pub enum Task {
impl Task {
pub fn get_uid(&self) -> u32 {
match self {
Self::Enqueued { content } | Self::Processing { content } => *content.as_ref(),
Self::Enqueued { content } => *content.as_ref(),
Self::Processing { content } => *content.as_ref(),
Self::Failed { content } => *content.as_ref(),
Self::Succeeded { content } => *content.as_ref(),
}
Expand Down Expand Up @@ -432,7 +452,8 @@ impl Task {
impl AsRef<u32> for Task {
fn as_ref(&self) -> &u32 {
match self {
Self::Enqueued { content } | Self::Processing { content } => content.as_ref(),
Self::Enqueued { content } => content.as_ref(),
Self::Processing { content } => content.as_ref(),
Self::Succeeded { content } => content.as_ref(),
Self::Failed { content } => content.as_ref(),
}
Expand Down Expand Up @@ -759,7 +780,8 @@ mod test {
assert!(matches!(
task,
Task::Processing {
content: EnqueuedTask {
content: ProcessingTask {
started_at,
update_type: TaskType::DocumentAdditionOrUpdate {
details: Some(DocumentAdditionOrUpdate {
received_documents: 19547,
Expand All @@ -770,6 +792,10 @@ mod test {
..
}
}
if started_at == OffsetDateTime::parse(
"2022-02-03T15:17:02.812338Z",
&::time::format_description::well_known::Rfc3339
).unwrap()
));

let task: Task = serde_json::from_str(
Expand Down
Loading