add 'entry' key to tasks when created

This commit is contained in:
Dustin J. Mitchell 2022-01-06 02:18:32 +00:00
parent d6efad06ee
commit 9824ac1fd3
3 changed files with 15 additions and 1 deletions

View file

@ -108,6 +108,7 @@ impl Replica {
let mut task = Task::new(uuid, taskmap).into_mut(self);
task.set_description(description)?;
task.set_status(status)?;
task.set_entry(Utc::now())?;
Ok(task.into_immut())
}
@ -228,7 +229,7 @@ mod tests {
..
} = op
{
if property == "modified" {
if property == "modified" || property == "entry" {
if value.is_some() {
value = Some("just-now".into());
}
@ -277,6 +278,13 @@ mod tests {
value: Some("pending".into()),
timestamp: now,
},
ReplicaOp::Update {
uuid: t.get_uuid(),
property: "entry".into(),
old_value: None,
value: Some("just-now".into()),
timestamp: now,
},
ReplicaOp::Update {
uuid: t.get_uuid(),
property: "modified".into(),

View file

@ -57,6 +57,7 @@ enum Prop {
Start,
Status,
Wait,
Entry,
}
#[allow(clippy::ptr_arg)]
@ -277,6 +278,10 @@ impl<'r> TaskMut<'r> {
self.set_string(Prop::Description.as_ref(), Some(description))
}
pub(crate) fn set_entry(&mut self, entry: DateTime<Utc>) -> anyhow::Result<()> {
self.set_timestamp(Prop::Entry.as_ref(), Some(entry))
}
pub fn set_wait(&mut self, wait: Option<DateTime<Utc>>) -> anyhow::Result<()> {
self.set_timestamp(Prop::Wait.as_ref(), wait)
}