diff --git a/backend/task/src/main.rs b/backend/task/src/main.rs index f81423f..ae3652d 100644 --- a/backend/task/src/main.rs +++ b/backend/task/src/main.rs @@ -1,9 +1,9 @@ use chrono::Utc; use sqlx::{postgres::PgPoolOptions, Pool, Postgres}; -use tasks::import_posts; use std::env; use std::sync::Arc; use std::time::Duration; +use tasks::import_posts; //mod config; mod tasks; @@ -19,15 +19,15 @@ pub struct TaskManager<'a> { #[derive(Debug, sqlx::FromRow)] pub struct TaskLog { - log_id: u8, - task_id: u8, + log_id: i32, + task_id: i32, created_at: chrono::DateTime, - task_status: TaskStatus, + task_status: String, finished_at: Option>, } #[derive(Debug)] -enum TaskStatus { +pub enum TaskStatus { Pending(String), Completed(String), Failed(String), @@ -87,12 +87,10 @@ impl<'a> TaskManager<'a> { let mut scheduler = job_scheduler::JobScheduler::new(); results.iter().for_each(|r| { println!("Registering job: {:?}", r.task_name); - - let job: _ = job_scheduler::Job::new(r.schedule.parse().unwrap(), || { - match r.task_id { - 1 => import_posts::register(&Arc::new(&self.pool)), - _ => panic!(), - } + + let job: _ = job_scheduler::Job::new(r.schedule.parse().unwrap(), || match r.task_id { + 1 => import_posts::register(&Arc::new(&self.pool)), + _ => panic!(), }); scheduler.add(job);