Add reader.v5.tasks.Task.created_at.

There was no way to "quickly" get the creation date.
This commit is contained in:
funilrys 2022-12-03 18:59:08 +01:00
parent cf50f85986
commit 1be4619b91
No known key found for this signature in database
GPG Key ID: 0D8BFEF5515C00C6

View File

@ -147,6 +147,38 @@ impl Task {
_ => None,
}
}
pub fn created_at(&self) -> Option<OffsetDateTime> {
match &self.content {
TaskContent::IndexCreation { index_uid: _, primary_key: _ } => {
match self.events.first() {
Some(TaskEvent::Created(ts)) => Some(*ts),
_ => None,
}
}
TaskContent::DocumentAddition {
index_uid: _,
content_uuid: _,
merge_strategy: _,
primary_key: _,
documents_count: _,
allow_index_creation: _,
} => match self.events.first() {
Some(TaskEvent::Created(ts)) => Some(*ts),
_ => None,
},
TaskContent::SettingsUpdate {
index_uid: _,
settings: _,
is_deletion: _,
allow_index_creation: _,
} => match self.events.first() {
Some(TaskEvent::Created(ts)) => Some(*ts),
_ => None,
},
_ => None,
}
}
}
impl IndexUid {