Skip to content

Commit

Permalink
[change] move todo models to another module
Browse files Browse the repository at this point in the history
  • Loading branch information
seqre committed Mar 12, 2023
1 parent 8921961 commit 1a9fb96
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/commands/todo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use tokio_stream::{self as stream, StreamExt};
use tracing::debug;

use crate::{
models::{NewTodo, Todo},
models::todo::{NewTodo, Todo},
Conn, Context, Result,
};

Expand Down
24 changes: 1 addition & 23 deletions src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
use diesel::{Insertable, Queryable};

use crate::schema::todos;

#[derive(Queryable, Debug)]
pub struct Todo {
pub channel_id: i64,
pub id: i32,
pub todo: String,
pub creation_date: String,
pub completion_date: Option<String>,
pub assignee: Option<i64>,
}

#[derive(Insertable)]
#[diesel(table_name = todos)]
pub struct NewTodo<'a> {
pub channel_id: &'a i64,
pub id: &'a i32,
pub todo: &'a str,
pub creation_date: &'a str,
pub assignee: Option<i64>,
}
pub mod todo;
23 changes: 23 additions & 0 deletions src/models/todo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use diesel::{Insertable, Queryable};

use crate::schema::todos;

#[derive(Queryable, Debug)]
pub struct Todo {
pub channel_id: i64,
pub id: i32,
pub todo: String,
pub creation_date: String,
pub completion_date: Option<String>,
pub assignee: Option<i64>,
}

#[derive(Insertable)]
#[diesel(table_name = todos)]
pub struct NewTodo<'a> {
pub channel_id: &'a i64,
pub id: &'a i32,
pub todo: &'a str,
pub creation_date: &'a str,
pub assignee: Option<i64>,
}
2 changes: 1 addition & 1 deletion src/tasks/todo_reminder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use itertools::Itertools;
use poise::serenity_prelude::{async_trait, ChannelId, Http};
use tokio::time::Duration;

use crate::{models::Todo, tasks::Task, Conn};
use crate::{models::todo::Todo, tasks::Task, Conn};

pub struct TodoReminderTask {
db: Conn,
Expand Down

0 comments on commit 1a9fb96

Please # to comment.