diff --git a/src/main.rs b/src/main.rs index 12bffea..96fb41a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +mod project; + fn main() { println!("Starting server on localhost:8080"); diff --git a/src/project.rs b/src/project.rs new file mode 100644 index 0000000..6d77534 --- /dev/null +++ b/src/project.rs @@ -0,0 +1,26 @@ +pub struct Project { + pub id: i64, + pub title: String, + pub created_time: i64, + pub last_modified_time: i64, + pub percentage_completed: i32, + pub archived: bool, +} + +impl Project { + pub fn new(title: String) -> Self { + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_secs() as i64; + + Self { + id: 0, + title, + created_time: now, + last_modified_time: now, + percentage_completed: 0, + archived: false, + } + } +} diff --git a/todo.md b/todo.md index 63a671a..5a67a2e 100644 --- a/todo.md +++ b/todo.md @@ -2,7 +2,7 @@ [x] Template a Rouille server that always returns an empty 404. [x] Create a database schema. There should just be one table for now: `projects`. The Projects table contains info about each project in the board. The table should have columns for title, created time, last modified time, percentage completed (integer), and a flag for archived. Since this is a single-user server, there doesn't need to be an metadata about whose project it is. -[ ] Create a `Project` struct that corresponds to the schema definition. +[x] Create a `Project` struct that corresponds to the schema definition. [ ] Create a module or struct at your discretion for interfacing with the database. Create functions for the following: create a project, update a project's progress, archive a project, unarchive a project, and list of all projects. [ ] Create a `main.css` file in src. Use mvp.css as a starting point. [ ] Create a `project-card.js` file in src that creates a web component for displaying a project.