What happens on a task is an event
Browse files at this commit09816e867c4e00d5f317d092b8545bfac7c823b2Parent: 40e817f- feat
- what happens on a task is an event
6 changed files +212 -41
- crates/izlek-core/src/detail.rs +4 -0
- crates/izlek-core/src/mail.rs +3 -0
- crates/izlek-core/src/store/mod.rs +45 -7
- crates/izlek-core/src/store/turso_store.rs +92 -30
- crates/izlek-core/tests/store.rs +64 -4
- crates/izlek-web/src/logs.rs +4 -0
crates/izlek-core/src/detail.rsmodified+4 -0
| @@ -132,6 +132,7 @@ pub enum ActivityKind { | ||
| 132 | 132 | Moved, |
| 133 | 133 | Unblocked, |
| 134 | 134 | Deleted, |
| 135 | + Commented, | |
| 135 | 136 | /// A kind written by a newer version than the one reading it. The stored |
| 136 | 137 | /// detail is shown as-is rather than dropping the row. |
| 137 | 138 | Other(String), |
| @@ -152,6 +153,7 @@ impl ActivityKind { | ||
| 152 | 153 | ActivityKind::Moved => "moved", |
| 153 | 154 | ActivityKind::Unblocked => "unblocked", |
| 154 | 155 | ActivityKind::Deleted => "deleted", |
| 156 | + ActivityKind::Commented => "commented", | |
| 155 | 157 | ActivityKind::Other(raw) => raw, |
| 156 | 158 | } |
| 157 | 159 | } |
| @@ -170,6 +172,7 @@ impl ActivityKind { | ||
| 170 | 172 | "moved" => ActivityKind::Moved, |
| 171 | 173 | "unblocked" => ActivityKind::Unblocked, |
| 172 | 174 | "deleted" => ActivityKind::Deleted, |
| 175 | + "commented" => ActivityKind::Commented, | |
| 173 | 176 | other => ActivityKind::Other(other.to_string()), |
| 174 | 177 | } |
| 175 | 178 | } |
| @@ -205,6 +208,7 @@ impl ActivityEntry { | ||
| 205 | 208 | ActivityKind::Moved => format!("moved {detail}"), |
| 206 | 209 | ActivityKind::Unblocked => format!("unblocked this task — {detail}"), |
| 207 | 210 | ActivityKind::Deleted => "deleted this task".to_string(), |
| 211 | + ActivityKind::Commented => "commented".to_string(), | |
| 208 | 212 | ActivityKind::Other(_) => detail.to_string(), |
| 209 | 213 | } |
| 210 | 214 | } |
crates/izlek-core/src/mail.rsmodified+3 -0
| @@ -611,6 +611,9 @@ impl Engine { | ||
| 611 | 611 | "{} deleted {} — {}, the last task it was waiting on.", |
| 612 | 612 | actor, freeing.cause_key, freeing.cause_title |
| 613 | 613 | ), |
| 614 | + // Not a wired path yet — S4's work — so this only needs to be | |
| 615 | + // exhaustive, not right. | |
| 616 | + (Event::Happened(_), _) => format!("{} touched it.", actor), | |
| 614 | 617 | }; |
| 615 | 618 | let body = format!( |
| 616 | 619 | "{key} — {title}\n\n{happened}\n\n{when}\n\n{base}/?task={id}\n", |
crates/izlek-core/src/store/mod.rsmodified+45 -7
| @@ -206,6 +206,23 @@ pub struct NewTask<'a> { | ||
| 206 | 206 | pub created_by: &'a str, |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | +/// What `create_task` wrote: the task, and the id of the Created activity row | |
| 210 | +/// it filed alongside it, so a caller that needs to name the event — a mail | |
| 211 | +/// retry, one day — does not have to go read the trail back. | |
| 212 | +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | |
| 213 | +pub struct TaskCreated { | |
| 214 | + pub row: TaskRow, | |
| 215 | + pub activity_id: String, | |
| 216 | +} | |
| 217 | + | |
| 218 | +/// What `add_comment` wrote: the comment's id, and the id of the Commented | |
| 219 | +/// activity row it filed alongside it in the same transaction. | |
| 220 | +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | |
| 221 | +pub struct CommentWritten { | |
| 222 | + pub comment_id: String, | |
| 223 | + pub activity_id: String, | |
| 224 | +} | |
| 225 | + | |
| 209 | 226 | /// What makes a rule fire. |
| 210 | 227 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| 211 | 228 | pub enum Trigger { |
| @@ -406,7 +423,21 @@ pub struct Deletion { | ||
| 406 | 423 | pub event: Option<Freeing>, |
| 407 | 424 | } |
| 408 | 425 | |
| 409 | -/// The two things that can owe a mail. Both are committed facts with an id, an | |
| 426 | +/// One row of a task's activity trail, as an event a rule can fire on. Covers | |
| 427 | +/// everything `record_activity` writes that is not already its own event | |
| 428 | +/// shape — a comment today, whatever else `ActivityKind` grows later. | |
| 429 | +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | |
| 430 | +pub struct ActivityEvent { | |
| 431 | + pub id: String, | |
| 432 | + pub task_id: String, | |
| 433 | + pub board_id: String, | |
| 434 | + pub kind: ActivityKind, | |
| 435 | + pub actor_id: String, | |
| 436 | + pub detail: String, | |
| 437 | + pub at: OffsetDateTime, | |
| 438 | +} | |
| 439 | + | |
| 440 | +/// The things that can owe a mail. Each is a committed fact with an id, an | |
| 410 | 441 | /// actor and a moment, and a retry rebuilds its mail from whichever one the |
| 411 | 442 | /// ledger row points at. |
| 412 | 443 | #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| @@ -415,6 +446,8 @@ pub enum Event { | ||
| 415 | 446 | Moved(crate::board::Transition), |
| 416 | 447 | /// A blocker was deleted and let something go. |
| 417 | 448 | Freed(Freeing), |
| 449 | + /// An activity row that is neither of the above — a comment, today. | |
| 450 | + Happened(ActivityEvent), | |
| 418 | 451 | } |
| 419 | 452 | |
| 420 | 453 | impl Event { |
| @@ -422,6 +455,7 @@ impl Event { | ||
| 422 | 455 | match self { |
| 423 | 456 | Event::Moved(transition) => &transition.id, |
| 424 | 457 | Event::Freed(freeing) => &freeing.id, |
| 458 | + Event::Happened(activity) => &activity.id, | |
| 425 | 459 | } |
| 426 | 460 | } |
| 427 | 461 | |
| @@ -431,6 +465,7 @@ impl Event { | ||
| 431 | 465 | match self { |
| 432 | 466 | Event::Moved(transition) => &transition.actor_id, |
| 433 | 467 | Event::Freed(freeing) => &freeing.actor_id, |
| 468 | + Event::Happened(activity) => &activity.actor_id, | |
| 434 | 469 | } |
| 435 | 470 | } |
| 436 | 471 | |
| @@ -439,6 +474,7 @@ impl Event { | ||
| 439 | 474 | match self { |
| 440 | 475 | Event::Moved(transition) => transition.at, |
| 441 | 476 | Event::Freed(freeing) => freeing.at, |
| 477 | + Event::Happened(activity) => activity.at, | |
| 442 | 478 | } |
| 443 | 479 | } |
| 444 | 480 | } |
| @@ -603,7 +639,7 @@ pub trait Store: BoardReads + DetailReads + 'static { | ||
| 603 | 639 | |
| 604 | 640 | /// Writes a task and hands it the next key on its board, in one |
| 605 | 641 | /// transaction, so two writers cannot both take `DZ-14`. |
| 606 | - async fn create_task(&self, new: NewTask<'_>) -> Result<TaskRow>; | |
| 642 | + async fn create_task(&self, new: NewTask<'_>) -> Result<TaskCreated>; | |
| 607 | 643 | |
| 608 | 644 | /// Idempotent: assigning someone twice is not an error. |
| 609 | 645 | async fn assign_task(&self, task_id: &str, user_id: &str) -> Result<()>; |
| @@ -631,14 +667,16 @@ pub trait Store: BoardReads + DetailReads + 'static { | ||
| 631 | 667 | ) -> Result<()>; |
| 632 | 668 | |
| 633 | 669 | /// The author is the session's user, decided by the handler. There is no |
| 634 | - /// author field on the form. | |
| 670 | + /// author field on the form. Writes the comment and its Commented | |
| 671 | + /// activity row in the same transaction, so one never exists without the | |
| 672 | + /// other. | |
| 635 | 673 | async fn add_comment( |
| 636 | 674 | &self, |
| 637 | 675 | task_id: &str, |
| 638 | 676 | author_id: &str, |
| 639 | 677 | body: &str, |
| 640 | 678 | at: OffsetDateTime, |
| 641 | - ) -> Result<String>; | |
| 679 | + ) -> Result<CommentWritten>; | |
| 642 | 680 | |
| 643 | 681 | /// Hangs a file off a task. The bytes go into the database file with the |
| 644 | 682 | /// row: there is no second place for a Izlek deployment to keep, and no |
| @@ -717,8 +755,8 @@ pub trait Store: BoardReads + DetailReads + 'static { | ||
| 717 | 755 | /// only; nothing here writes. |
| 718 | 756 | async fn deletion_cost(&self, task_id: &str) -> Result<Option<DeletionCost>>; |
| 719 | 757 | |
| 720 | - /// Appends one line to a task's activity trail. `actor_id` is `None` when | |
| 721 | - /// the system did it rather than a person. | |
| 758 | + /// Appends one line to a task's activity trail and returns its row id. | |
| 759 | + /// `actor_id` is `None` when the system did it rather than a person. | |
| 722 | 760 | async fn record_activity( |
| 723 | 761 | &self, |
| 724 | 762 | task_id: &str, |
| @@ -726,7 +764,7 @@ pub trait Store: BoardReads + DetailReads + 'static { | ||
| 726 | 764 | kind: &ActivityKind, |
| 727 | 765 | detail: &str, |
| 728 | 766 | at: OffsetDateTime, |
| 729 | - ) -> Result<()>; | |
| 767 | + ) -> Result<String>; | |
| 730 | 768 | |
| 731 | 769 | // -- mail rules -------------------------------------------------------- |
| 732 | 770 |
crates/izlek-core/src/store/turso_store.rsmodified+92 -30
| @@ -15,9 +15,10 @@ use uuid::Uuid; | ||
| 15 | 15 | |
| 16 | 16 | use super::secret; |
| 17 | 17 | use super::{ |
| 18 | - ActivityLine, Attachment, Audience, Deletion, Event, Freeing, MailDecision, MailOutcome, | |
| 19 | - MailRule, MailSend, NewAttachment, NewSender, NewTask, NewUser, Recipient, Result, SendKind, | |
| 20 | - SendState, SenderTest, Session, SigninLink, Store, StoreError, Trigger, User, Workspace, | |
| 18 | + ActivityEvent, ActivityLine, Attachment, Audience, CommentWritten, Deletion, Event, Freeing, | |
| 19 | + MailDecision, MailOutcome, MailRule, MailSend, NewAttachment, NewSender, NewTask, NewUser, | |
| 20 | + Recipient, Result, SendKind, SendState, SenderTest, Session, SigninLink, Store, StoreError, | |
| 21 | + TaskCreated, Trigger, User, Workspace, | |
| 21 | 22 | }; |
| 22 | 23 | use crate::Role; |
| 23 | 24 | use crate::board::{BoardMeta, BoardReads, Column, Moved, Person, TaskRow, Transition}; |
| @@ -1178,8 +1179,9 @@ impl Store for TursoStore { | ||
| 1178 | 1179 | }) |
| 1179 | 1180 | } |
| 1180 | 1181 | |
| 1181 | - async fn create_task(&self, new: NewTask<'_>) -> Result<TaskRow> { | |
| 1182 | + async fn create_task(&self, new: NewTask<'_>) -> Result<TaskCreated> { | |
| 1182 | 1183 | let id = Uuid::new_v4().to_string(); |
| 1184 | + let activity_id = Uuid::new_v4().to_string(); | |
| 1183 | 1185 | let now = now_text()?; |
| 1184 | 1186 | let deadline = new.deadline.map(day_text).transpose()?; |
| 1185 | 1187 | |
| @@ -1248,7 +1250,7 @@ impl Store for TursoStore { | ||
| 1248 | 1250 | "INSERT INTO activity (id, task_id, actor_id, kind, detail, created_at) \ |
| 1249 | 1251 | VALUES (?1, ?2, ?3, ?4, '', ?5)", |
| 1250 | 1252 | params![ |
| 1251 | - Uuid::new_v4().to_string(), | |
| 1253 | + activity_id.clone(), | |
| 1252 | 1254 | id.clone(), |
| 1253 | 1255 | new.created_by, |
| 1254 | 1256 | ActivityKind::Created.as_str(), |
| @@ -1274,14 +1276,17 @@ impl Store for TursoStore { | ||
| 1274 | 1276 | tx.commit().await.map_err(backend)?; |
| 1275 | 1277 | |
| 1276 | 1278 | let (task_key, position) = written; |
| 1277 | - Ok(TaskRow { | |
| 1278 | - id, | |
| 1279 | - task_key, | |
| 1280 | - title: new.title.to_string(), | |
| 1281 | - column_id: new.column_id.to_string(), | |
| 1282 | - deadline: new.deadline, | |
| 1283 | - position, | |
| 1284 | - done_at: None, | |
| 1279 | + Ok(TaskCreated { | |
| 1280 | + row: TaskRow { | |
| 1281 | + id, | |
| 1282 | + task_key, | |
| 1283 | + title: new.title.to_string(), | |
| 1284 | + column_id: new.column_id.to_string(), | |
| 1285 | + deadline: new.deadline, | |
| 1286 | + position, | |
| 1287 | + done_at: None, | |
| 1288 | + }, | |
| 1289 | + activity_id, | |
| 1285 | 1290 | }) |
| 1286 | 1291 | } |
| 1287 | 1292 | |
| @@ -1422,17 +1427,50 @@ impl Store for TursoStore { | ||
| 1422 | 1427 | author_id: &str, |
| 1423 | 1428 | body: &str, |
| 1424 | 1429 | at: OffsetDateTime, |
| 1425 | - ) -> Result<String> { | |
| 1426 | - let id = Uuid::new_v4().to_string(); | |
| 1427 | - self.conn | |
| 1428 | - .execute( | |
| 1430 | + ) -> Result<CommentWritten> { | |
| 1431 | + let comment_id = Uuid::new_v4().to_string(); | |
| 1432 | + let activity_id = Uuid::new_v4().to_string(); | |
| 1433 | + let when = stamp(at)?; | |
| 1434 | + | |
| 1435 | + let mut conn = self.tx_conn().await?; | |
| 1436 | + let tx = conn | |
| 1437 | + .transaction_with_behavior(TransactionBehavior::Immediate) | |
| 1438 | + .await | |
| 1439 | + .map_err(backend)?; | |
| 1440 | + | |
| 1441 | + let written = async { | |
| 1442 | + tx.execute( | |
| 1429 | 1443 | "INSERT INTO comment (id, task_id, author_id, body, created_at) \ |
| 1430 | 1444 | VALUES (?1, ?2, ?3, ?4, ?5)", |
| 1431 | - params![id.clone(), task_id, author_id, body, stamp(at)?], | |
| 1445 | + params![comment_id.clone(), task_id, author_id, body, when.clone()], | |
| 1432 | 1446 | ) |
| 1433 | - .await | |
| 1434 | - .map_err(backend)?; | |
| 1435 | - Ok(id) | |
| 1447 | + .await?; | |
| 1448 | + tx.execute( | |
| 1449 | + "INSERT INTO activity (id, task_id, actor_id, kind, detail, created_at) \ | |
| 1450 | + VALUES (?1, ?2, ?3, ?4, '', ?5)", | |
| 1451 | + params![ | |
| 1452 | + activity_id.clone(), | |
| 1453 | + task_id, | |
| 1454 | + author_id, | |
| 1455 | + ActivityKind::Commented.as_str(), | |
| 1456 | + when.clone() | |
| 1457 | + ], | |
| 1458 | + ) | |
| 1459 | + .await?; | |
| 1460 | + Ok::<_, turso::Error>(()) | |
| 1461 | + } | |
| 1462 | + .await; | |
| 1463 | + | |
| 1464 | + if let Err(e) = written { | |
| 1465 | + let _ = tx.rollback().await; | |
| 1466 | + return Err(backend(e)); | |
| 1467 | + } | |
| 1468 | + tx.commit().await.map_err(backend)?; | |
| 1469 | + | |
| 1470 | + Ok(CommentWritten { | |
| 1471 | + comment_id, | |
| 1472 | + activity_id, | |
| 1473 | + }) | |
| 1436 | 1474 | } |
| 1437 | 1475 | |
| 1438 | 1476 | async fn add_attachment(&self, new: NewAttachment<'_>) -> Result<String> { |
| @@ -2009,13 +2047,14 @@ impl Store for TursoStore { | ||
| 2009 | 2047 | kind: &ActivityKind, |
| 2010 | 2048 | detail: &str, |
| 2011 | 2049 | at: OffsetDateTime, |
| 2012 | - ) -> Result<()> { | |
| 2050 | + ) -> Result<String> { | |
| 2051 | + let id = Uuid::new_v4().to_string(); | |
| 2013 | 2052 | self.conn |
| 2014 | 2053 | .execute( |
| 2015 | 2054 | "INSERT INTO activity (id, task_id, actor_id, kind, detail, created_at) \ |
| 2016 | 2055 | VALUES (?1, ?2, ?3, ?4, ?5, ?6)", |
| 2017 | 2056 | params![ |
| 2018 | - Uuid::new_v4().to_string(), | |
| 2057 | + id.clone(), | |
| 2019 | 2058 | task_id, |
| 2020 | 2059 | actor_id, |
| 2021 | 2060 | kind.as_str(), |
| @@ -2025,7 +2064,7 @@ impl Store for TursoStore { | ||
| 2025 | 2064 | ) |
| 2026 | 2065 | .await |
| 2027 | 2066 | .map_err(backend)?; |
| 2028 | - Ok(()) | |
| 2067 | + Ok(id) | |
| 2029 | 2068 | } |
| 2030 | 2069 | |
| 2031 | 2070 | // -- mail rules -------------------------------------------------------- |
| @@ -2148,13 +2187,36 @@ impl Store for TursoStore { | ||
| 2148 | 2187 | ) |
| 2149 | 2188 | .await? |
| 2150 | 2189 | { |
| 2151 | - Some(row) => Ok(Some(Event::Freed(Freeing { | |
| 2190 | + Some(row) => { | |
| 2191 | + return Ok(Some(Event::Freed(Freeing { | |
| 2192 | + id: text(&row, 0)?, | |
| 2193 | + board_id: text(&row, 1)?, | |
| 2194 | + cause_key: text(&row, 2)?, | |
| 2195 | + cause_title: text(&row, 3)?, | |
| 2196 | + actor_id: text(&row, 4)?, | |
| 2197 | + at: parse_stamp(&text(&row, 5)?)?, | |
| 2198 | + }))); | |
| 2199 | + } | |
| 2200 | + None => {} | |
| 2201 | + } | |
| 2202 | + match self | |
| 2203 | + .one_row( | |
| 2204 | + "SELECT activity.id, activity.task_id, task.board_id, activity.kind, \ | |
| 2205 | + activity.actor_id, activity.detail, activity.created_at \ | |
| 2206 | + FROM activity JOIN task ON task.id = activity.task_id \ | |
| 2207 | + WHERE activity.id = ?1", | |
| 2208 | + params![event_id], | |
| 2209 | + ) | |
| 2210 | + .await? | |
| 2211 | + { | |
| 2212 | + Some(row) => Ok(Some(Event::Happened(ActivityEvent { | |
| 2152 | 2213 | id: text(&row, 0)?, |
| 2153 | - board_id: text(&row, 1)?, | |
| 2154 | - cause_key: text(&row, 2)?, | |
| 2155 | - cause_title: text(&row, 3)?, | |
| 2156 | - actor_id: text(&row, 4)?, | |
| 2157 | - at: parse_stamp(&text(&row, 5)?)?, | |
| 2214 | + task_id: text(&row, 1)?, | |
| 2215 | + board_id: text(&row, 2)?, | |
| 2216 | + kind: ActivityKind::parse(&text(&row, 3)?), | |
| 2217 | + actor_id: opt_text(&row, 4)?.unwrap_or_default(), | |
| 2218 | + detail: text(&row, 5)?, | |
| 2219 | + at: parse_stamp(&text(&row, 6)?)?, | |
| 2158 | 2220 | }))), |
| 2159 | 2221 | None => Ok(None), |
| 2160 | 2222 | } |
crates/izlek-core/tests/store.rsmodified+64 -4
| @@ -9,8 +9,8 @@ use std::path::PathBuf; | ||
| 9 | 9 | use izlek_core::Role; |
| 10 | 10 | use izlek_core::auth::{Token, hash_password}; |
| 11 | 11 | use izlek_core::store::{ |
| 12 | - Audience, MailOutcome, MailRule, NewAttachment, NewSender, NewUser, SendKind, SendState, Store, | |
| 13 | - StoreError, Trigger, TursoStore, User, | |
| 12 | + Audience, Event, MailOutcome, MailRule, NewAttachment, NewSender, NewUser, SendKind, | |
| 13 | + SendState, Store, StoreError, Trigger, TursoStore, User, | |
| 14 | 14 | }; |
| 15 | 15 | use time::{Duration, OffsetDateTime}; |
| 16 | 16 | use uuid::Uuid; |
| @@ -1869,6 +1869,7 @@ async fn add_task( | ||
| 1869 | 1869 | }) |
| 1870 | 1870 | .await |
| 1871 | 1871 | .unwrap() |
| 1872 | + .row | |
| 1872 | 1873 | .id |
| 1873 | 1874 | } |
| 1874 | 1875 | |
| @@ -2538,8 +2539,9 @@ async fn a_task_detail_costs_eight_queries_whatever_it_carries() { | ||
| 2538 | 2539 | assert_eq!(detail.comments.len(), 20); |
| 2539 | 2540 | assert_eq!(detail.assignees.len(), 20); |
| 2540 | 2541 | assert_eq!(detail.blocks.len(), 20); |
| 2541 | - // Twenty moves plus the line create_task wrote. | |
| 2542 | - assert_eq!(detail.activity.len(), 21); | |
| 2542 | + // Twenty comments (each its own Commented line), twenty moves, plus the | |
| 2543 | + // line create_task wrote. | |
| 2544 | + assert_eq!(detail.activity.len(), 41); | |
| 2543 | 2545 | assert_eq!( |
| 2544 | 2546 | counted.count(), |
| 2545 | 2547 | 8, |
| @@ -4381,3 +4383,61 @@ async fn the_activity_feed_is_the_whole_workspace_newest_first() { | ||
| 4381 | 4383 | assert_eq!(feed[1].task_id, task_a); |
| 4382 | 4384 | assert_eq!(feed[1].actor_name.as_deref(), Some("Ada")); |
| 4383 | 4385 | } |
| 4386 | + | |
| 4387 | +#[tokio::test] | |
| 4388 | +async fn a_comment_leaves_one_activity_row_that_resolves_as_an_event() { | |
| 4389 | + let (scratch, workspace, admin) = workspace_with_admin().await; | |
| 4390 | + let store = &scratch.store; | |
| 4391 | + let task = add_task(store, &workspace, "Backlog", "note me", None, &admin).await; | |
| 4392 | + | |
| 4393 | + let written = store | |
| 4394 | + .add_comment(&task, &admin, "hello", OffsetDateTime::now_utc()) | |
| 4395 | + .await | |
| 4396 | + .unwrap(); | |
| 4397 | + | |
| 4398 | + let activity = store.activity_for_task(&task).await.unwrap(); | |
| 4399 | + let commented: Vec<_> = activity | |
| 4400 | + .iter() | |
| 4401 | + .filter(|line| line.kind == ActivityKind::Commented) | |
| 4402 | + .collect(); | |
| 4403 | + assert_eq!(commented.len(), 1); | |
| 4404 | + assert_eq!(commented[0].id, written.activity_id); | |
| 4405 | + | |
| 4406 | + match store.event(&written.activity_id).await.unwrap() { | |
| 4407 | + Some(Event::Happened(event)) => { | |
| 4408 | + assert_eq!(event.task_id, task); | |
| 4409 | + assert_eq!(event.actor_id, admin); | |
| 4410 | + assert_eq!(event.kind, ActivityKind::Commented); | |
| 4411 | + } | |
| 4412 | + other => panic!("expected Event::Happened, got {other:?}"), | |
| 4413 | + } | |
| 4414 | +} | |
| 4415 | + | |
| 4416 | +#[tokio::test] | |
| 4417 | +async fn a_created_task_s_activity_id_resolves_as_an_event() { | |
| 4418 | + let (scratch, workspace, admin) = workspace_with_admin().await; | |
| 4419 | + let store = &scratch.store; | |
| 4420 | + let board = store.board(&workspace).await.unwrap().unwrap(); | |
| 4421 | + let column_id = column_named(store, &workspace, "Backlog").await; | |
| 4422 | + | |
| 4423 | + let created = store | |
| 4424 | + .create_task(NewTask { | |
| 4425 | + board_id: &board.id, | |
| 4426 | + column_id: &column_id, | |
| 4427 | + title: "brand new", | |
| 4428 | + description: "", | |
| 4429 | + deadline: None, | |
| 4430 | + created_by: &admin, | |
| 4431 | + }) | |
| 4432 | + .await | |
| 4433 | + .unwrap(); | |
| 4434 | + | |
| 4435 | + match store.event(&created.activity_id).await.unwrap() { | |
| 4436 | + Some(Event::Happened(event)) => { | |
| 4437 | + assert_eq!(event.task_id, created.row.id); | |
| 4438 | + assert_eq!(event.actor_id, admin); | |
| 4439 | + assert_eq!(event.kind, ActivityKind::Created); | |
| 4440 | + } | |
| 4441 | + other => panic!("expected Event::Happened, got {other:?}"), | |
| 4442 | + } | |
| 4443 | +} |
crates/izlek-web/src/logs.rsmodified+4 -0
| @@ -100,6 +100,7 @@ fn activity_sentence(kind: &izlek_core::detail::ActivityKind, detail: &str) -> S | ||
| 100 | 100 | ActivityKind::Moved => format!("moved {detail}"), |
| 101 | 101 | ActivityKind::Unblocked => format!("unblocked this task — {detail}"), |
| 102 | 102 | ActivityKind::Deleted => "deleted this task".to_string(), |
| 103 | + ActivityKind::Commented => "commented".to_string(), | |
| 103 | 104 | ActivityKind::Other(_) => detail.to_string(), |
| 104 | 105 | } |
| 105 | 106 | } |
| @@ -129,6 +130,9 @@ async fn event_happened( | ||
| 129 | 130 | .map(|column| format!("moved to {}", column.name))) |
| 130 | 131 | } |
| 131 | 132 | Event::Freed(_) => Ok(Some("unblocked".to_string())), |
| 133 | + // Not a wired path yet — S4's work — so this only needs to be | |
| 134 | + // exhaustive, not right. | |
| 135 | + Event::Happened(activity) => Ok(Some(activity.kind.as_str().to_string())), | |
| 132 | 136 | } |
| 133 | 137 | } |
| 134 | 138 |