|
|
@@ -22,12 +22,13 @@ use crate::{
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, SerialEncodable, SerialDecodable, PartialEq, Eq)]
|
|
|
struct TaskEvent {
|
|
|
action: String,
|
|
|
+ content: String,
|
|
|
timestamp: Timestamp,
|
|
|
}
|
|
|
|
|
|
impl TaskEvent {
|
|
|
- fn new(action: String) -> Self {
|
|
|
- Self { action, timestamp: Timestamp::current_time() }
|
|
|
+ fn new(action: String, content: String) -> Self {
|
|
|
+ Self { action, content, timestamp: Timestamp::current_time() }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -70,6 +71,7 @@ pub struct TaskInfo {
|
|
|
due: Option<Timestamp>,
|
|
|
rank: f32,
|
|
|
created_at: Timestamp,
|
|
|
+ state: String,
|
|
|
events: TaskEvents,
|
|
|
comments: TaskComments,
|
|
|
}
|
|
|
@@ -115,6 +117,7 @@ impl TaskInfo {
|
|
|
due,
|
|
|
rank,
|
|
|
created_at,
|
|
|
+ state: "open".into(),
|
|
|
comments: TaskComments(vec![]),
|
|
|
events: TaskEvents(vec![]),
|
|
|
})
|
|
|
@@ -156,11 +159,7 @@ impl TaskInfo {
|
|
|
|
|
|
pub fn get_state(&self) -> String {
|
|
|
debug!(target: "tau", "TaskInfo::get_state()");
|
|
|
- if let Some(ev) = self.events.0.last() {
|
|
|
- ev.action.clone()
|
|
|
- } else {
|
|
|
- "open".into()
|
|
|
- }
|
|
|
+ self.state.clone()
|
|
|
}
|
|
|
|
|
|
pub fn get_path(ref_id: &str, dataset_path: &Path) -> PathBuf {
|
|
|
@@ -186,6 +185,7 @@ impl TaskInfo {
|
|
|
pub fn set_assign(&mut self, assign: &[String]) {
|
|
|
debug!(target: "tau", "TaskInfo::set_assign()");
|
|
|
self.assign = TaskAssigns(assign.to_owned());
|
|
|
+ self.set_event("assign", &assign.join(", "));
|
|
|
}
|
|
|
|
|
|
pub fn set_project(&mut self, project: &[String]) {
|
|
|
@@ -195,7 +195,8 @@ impl TaskInfo {
|
|
|
|
|
|
pub fn set_comment(&mut self, c: Comment) {
|
|
|
debug!(target: "tau", "TaskInfo::set_comment()");
|
|
|
- self.comments.0.push(c);
|
|
|
+ self.comments.0.push(c.clone());
|
|
|
+ self.set_event("comment", &c.author);
|
|
|
}
|
|
|
|
|
|
pub fn set_rank(&mut self, r: f32) {
|
|
|
@@ -208,12 +209,20 @@ impl TaskInfo {
|
|
|
self.due = d;
|
|
|
}
|
|
|
|
|
|
- pub fn set_state(&mut self, action: &str) {
|
|
|
+ pub fn set_event(&mut self, action: &str, content: &str) {
|
|
|
+ debug!(target: "tau", "TaskInfo::set_event()");
|
|
|
+ if !content.is_empty() {
|
|
|
+ self.events.0.push(TaskEvent::new(action.into(), content.into()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ pub fn set_state(&mut self, state: &str) {
|
|
|
debug!(target: "tau", "TaskInfo::set_state()");
|
|
|
- if self.get_state() == action {
|
|
|
+ if self.get_state() == state {
|
|
|
return
|
|
|
}
|
|
|
- self.events.0.push(TaskEvent::new(action.into()));
|
|
|
+ self.state = state.to_string();
|
|
|
+ self.set_event("state", state);
|
|
|
}
|
|
|
}
|
|
|
|