timeline
Provides a tagged TimelineItem enum used by the task/artifact/iteration
detail templates, plus a builder that merges notes and semantic events for a
given entity and sorts them chronologically.
struct EventDisplay
pub(crate) struct EventDisplayA display-ready event entry for the activity timeline.
Fields are read by askama templates which the dead-code analysis can’t see.
| Field | Type | Description |
|---|---|---|
author_gravatar |
Option<String> | The author’s avatar URL, /avatars/<hash>, or None when the author has no email or is unknown. |
author_is_agent |
bool | Whether the author is an agent rather than a human; false when the author is unknown. |
author_name |
Option<String> | The author’s display name, or None when the entry has no author or the author is not found. |
created_at |
DateTime<Utc> | When the event happened, used to sort the timeline. |
created_at_display |
String | created_at formatted for the page as YYYY-MM-DD HH:MM UTC. |
display_text |
String | The sentence shown for the event, such as alice changed status from open to done. |
id_short |
String | The short form of the event’s id. |
struct NoteItem
pub(crate) struct NoteItemA display-ready note entry for the activity timeline.
| Field | Type | Description |
|---|---|---|
author_gravatar |
Option<String> | The author’s avatar URL, /avatars/<hash>, or None when the author has no email or is unknown. |
author_is_agent |
bool | Whether the author is an agent rather than a human; false when the author is unknown. |
author_name |
Option<String> | The author’s display name, or None when the entry has no author or the author is not found. |
body_html |
String | The note’s Markdown body rendered to HTML. |
created_at |
DateTime<Utc> | When the note was created, used to sort the timeline. |
created_at_display |
String | created_at formatted for the page as YYYY-MM-DD HH:MM UTC. |
id_short |
String | The short form of the note’s id. |
enum TimelineItem
pub(crate) enum TimelineItemA single entry in the activity timeline: either a note or a semantic event.
| Variant | Description |
|---|---|
Event(EventDisplay) |
A semantic event, such as a status or priority change. |
Note(NoteItem) |
A note added to the entity. |
TimelineItem::as_event
pub(crate) fn as_event(&self) -> Option<&EventDisplay>Template helper: return the event variant if present (for askama if let).
| Parameter | Type | Description |
|---|---|---|
| returns | Option<&EventDisplay> | The event, or None for a note. |
TimelineItem::as_note
pub(crate) fn as_note(&self) -> Option<&NoteItem>Template helper: return the note variant if present.
| Parameter | Type | Description |
|---|---|---|
| returns | Option<&NoteItem> | The note, or None for an event. |
TimelineItem::sort_key
fn sort_key(&self) -> DateTime<Utc>Return the creation timestamp used for chronological sorting.
| Parameter | Type | Description |
|---|---|---|
| returns | DateTime<Utc> | The created_at of the event or the note. |
fn build_timeline
pub(crate) async fn build_timeline(
conn: &Connection,
entity_type: EntityType,
entity_id: &Id,
) -> Result<Vec<TimelineItem>, String>Build the unified activity timeline for an entity.
Merges notes and semantic transaction events (filtering out events whose
semantic_type IS NULL), resolves author display data, and returns items
sorted by created_at ascending.
The sort is stable, and notes are added before events, so a note and an event with the same time keep that order.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the database connection |
entity_type |
EntityType | the kind of the entity |
entity_id |
&Id | the entity whose notes and events to show |
| returns | Result<Vec<TimelineItem>, String> | The timeline items, oldest first, or the database error as text. |
fn render_event_text
pub(crate) fn render_event_text(event: &SemanticEvent, author_name: Option<&str>) -> StringRender the human-readable action text for a semantic event.
Known semantic types (created, status-change, priority-change, phase-change and others)
get their own wording, using the event’s old and new values; an unknown type reads
performed <type>.
| Parameter | Type | Description |
|---|---|---|
event |
&SemanticEvent | the semantic event |
author_name |
Option<&str> | the author’s name, or None to write someone |
| returns | String | A sentence such as alice set priority to P1. |
fn build_event_display
async fn build_event_display(conn: &Connection, event: SemanticEvent) -> EventDisplayBuild an EventDisplay for a single semantic event.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the database connection, used to look up the author |
event |
SemanticEvent | the semantic event |
| returns | EventDisplay | The event, ready for the template. |
fn build_note_item
async fn build_note_item(conn: &Connection, note: note::Model) -> NoteItemBuild a NoteItem for a single note.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the database connection, used to look up the author |
note |
note::Model | the note |
| returns | NoteItem | The note with its body rendered to HTML, ready for the template. |
fn entity_table
fn entity_table(entity_type: EntityType) -> &'static strMap an EntityType to the transaction_events table_name value.
| Parameter | Type | Description |
|---|---|---|
entity_type |
EntityType | the kind of entity |
| returns | &'static str | artifacts, iterations or tasks. |