Skip to content

Commit e93c27b

Browse files
Merge #485
485: Add missing startedAt field in EnqueuedTask r=curquiza a=sebastiantoh # Pull Request ## Related issue Fixes #462 ## What does this PR do? Add missing startedAt field in EnqueuedTask ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Co-authored-by: Sebastian Toh <[email protected]>
2 parents 241e797 + 6e89795 commit e93c27b

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

src/indexes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ mod tests {
20272027
} => assert_eq!(index_uid, *index.uid),
20282028
Task::Processing {
20292029
content:
2030-
EnqueuedTask {
2030+
ProcessingTask {
20312031
index_uid: Some(index_uid),
20322032
..
20332033
},

src/tasks.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,25 @@ impl AsRef<u32> for EnqueuedTask {
181181
}
182182
}
183183

184+
#[derive(Debug, Clone, Deserialize)]
185+
#[serde(rename_all = "camelCase")]
186+
pub struct ProcessingTask {
187+
#[serde(with = "time::serde::rfc3339")]
188+
pub enqueued_at: OffsetDateTime,
189+
#[serde(with = "time::serde::rfc3339")]
190+
pub started_at: OffsetDateTime,
191+
pub index_uid: Option<String>,
192+
#[serde(flatten)]
193+
pub update_type: TaskType,
194+
pub uid: u32,
195+
}
196+
197+
impl AsRef<u32> for ProcessingTask {
198+
fn as_ref(&self) -> &u32 {
199+
&self.uid
200+
}
201+
}
202+
184203
#[derive(Debug, Clone, Deserialize)]
185204
#[serde(rename_all = "camelCase", tag = "status")]
186205
pub enum Task {
@@ -190,7 +209,7 @@ pub enum Task {
190209
},
191210
Processing {
192211
#[serde(flatten)]
193-
content: EnqueuedTask,
212+
content: ProcessingTask,
194213
},
195214
Failed {
196215
#[serde(flatten)]
@@ -205,7 +224,8 @@ pub enum Task {
205224
impl Task {
206225
pub fn get_uid(&self) -> u32 {
207226
match self {
208-
Self::Enqueued { content } | Self::Processing { content } => *content.as_ref(),
227+
Self::Enqueued { content } => *content.as_ref(),
228+
Self::Processing { content } => *content.as_ref(),
209229
Self::Failed { content } => *content.as_ref(),
210230
Self::Succeeded { content } => *content.as_ref(),
211231
}
@@ -432,7 +452,8 @@ impl Task {
432452
impl AsRef<u32> for Task {
433453
fn as_ref(&self) -> &u32 {
434454
match self {
435-
Self::Enqueued { content } | Self::Processing { content } => content.as_ref(),
455+
Self::Enqueued { content } => content.as_ref(),
456+
Self::Processing { content } => content.as_ref(),
436457
Self::Succeeded { content } => content.as_ref(),
437458
Self::Failed { content } => content.as_ref(),
438459
}
@@ -759,7 +780,8 @@ mod test {
759780
assert!(matches!(
760781
task,
761782
Task::Processing {
762-
content: EnqueuedTask {
783+
content: ProcessingTask {
784+
started_at,
763785
update_type: TaskType::DocumentAdditionOrUpdate {
764786
details: Some(DocumentAdditionOrUpdate {
765787
received_documents: 19547,
@@ -770,6 +792,10 @@ mod test {
770792
..
771793
}
772794
}
795+
if started_at == OffsetDateTime::parse(
796+
"2022-02-03T15:17:02.812338Z",
797+
&::time::format_description::well_known::Rfc3339
798+
).unwrap()
773799
));
774800

775801
let task: Task = serde_json::from_str(

0 commit comments

Comments
 (0)