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

@ -33,6 +33,7 @@ The following keys, and key formats, are defined:
* `start` - the most recent time at which this task was started (a task with no `start` key is not active) * `start` - the most recent time at which this task was started (a task with no `start` key is not active)
* `tag_<tag>` - indicates this task has tag `<tag>` (value is an empty string) * `tag_<tag>` - indicates this task has tag `<tag>` (value is an empty string)
* `wait` - indicates the time before which this task should be hidden, as it is not actionable * `wait` - indicates the time before which this task should be hidden, as it is not actionable
* `entry` - the time at which the task was created
* `annotation_<timestamp>` - value is an annotation created at the given time * `annotation_<timestamp>` - value is an annotation created at the given time
The following are not yet implemented: The following are not yet implemented:

View file

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

View file

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