My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
1use dto::{ DateTime, NanoId, TaskModelEx};
2
3use crate::types::{Group, Priority, Zettel};
4
5/// a `Task` that you have to complete!
6#[expect(dead_code)]
7#[derive(Debug, Clone)]
8pub struct Task {
9 /// Should only be constructed from models.
10 _private:(),
11
12 pub id: NanoId,
13 pub name: String,
14 pub priority: Priority,
15 pub due: Option<DateTime>,
16 pub finished_at: Option<DateTime>,
17 pub created_at: DateTime,
18 pub modified_at: DateTime,
19 /// Each task has its own related `Zettel`.
20 pub zettel: Zettel,
21 pub group: Group,
22}
23
24impl From<TaskModelEx> for Task {
25 fn from(value: TaskModelEx) -> Self {
26 Self {
27 _private: (),
28 id: value.nano_id,
29 name: value.name,
30 priority: value.priority.into(),
31 due: value.due,
32 finished_at: value.finished_at,
33 created_at: value.created_at,
34 modified_at: value.modified_at,
35 zettel: value
36 .zettel
37 .into_option()
38 .expect(
39 "When fetching a Task from the database, we expect to always have the Zettel loaded!!",
40 )
41 .into(),
42 group: value
43 .group
44 .into_option()
45 .expect(
46 "When fetching a Task from the database, we expect to always have the Group loaded!!",
47 )
48 .into(),
49
50 }
51 }
52}