redux of the worker queue
This commit is contained in:
@@ -3,17 +3,21 @@ pub mod artist;
|
||||
pub mod download_queue;
|
||||
pub mod playlist;
|
||||
pub mod playlist_track;
|
||||
pub mod scheduler_state;
|
||||
pub mod search_cache;
|
||||
pub mod track;
|
||||
pub mod user;
|
||||
pub mod wanted_item;
|
||||
pub mod work_queue;
|
||||
|
||||
pub use album::Entity as Albums;
|
||||
pub use artist::Entity as Artists;
|
||||
pub use download_queue::Entity as DownloadQueue;
|
||||
pub use playlist::Entity as Playlists;
|
||||
pub use playlist_track::Entity as PlaylistTracks;
|
||||
pub use scheduler_state::Entity as SchedulerStates;
|
||||
pub use search_cache::Entity as SearchCache;
|
||||
pub use track::Entity as Tracks;
|
||||
pub use user::Entity as Users;
|
||||
pub use wanted_item::Entity as WantedItems;
|
||||
pub use work_queue::Entity as WorkQueues;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "scheduler_state")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
#[sea_orm(unique)]
|
||||
pub job_name: String,
|
||||
#[sea_orm(nullable)]
|
||||
pub last_run_at: Option<chrono::NaiveDateTime>,
|
||||
#[sea_orm(nullable)]
|
||||
pub last_result: Option<String>,
|
||||
#[sea_orm(nullable)]
|
||||
pub next_run_at: Option<chrono::NaiveDateTime>,
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
@@ -0,0 +1,66 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(
|
||||
Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, EnumIter, DeriveActiveEnum,
|
||||
)]
|
||||
#[sea_orm(rs_type = "String", db_type = "Text")]
|
||||
pub enum WorkTaskType {
|
||||
#[sea_orm(string_value = "download")]
|
||||
Download,
|
||||
#[sea_orm(string_value = "index")]
|
||||
Index,
|
||||
#[sea_orm(string_value = "tag")]
|
||||
Tag,
|
||||
#[sea_orm(string_value = "organize")]
|
||||
Organize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, EnumIter, DeriveActiveEnum)]
|
||||
#[sea_orm(rs_type = "String", db_type = "Text")]
|
||||
pub enum WorkQueueStatus {
|
||||
#[sea_orm(string_value = "pending")]
|
||||
Pending,
|
||||
#[sea_orm(string_value = "running")]
|
||||
Running,
|
||||
#[sea_orm(string_value = "completed")]
|
||||
Completed,
|
||||
#[sea_orm(string_value = "failed")]
|
||||
Failed,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for WorkTaskType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Download => write!(f, "download"),
|
||||
Self::Index => write!(f, "index"),
|
||||
Self::Tag => write!(f, "tag"),
|
||||
Self::Organize => write!(f, "organize"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "work_queue")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub task_type: WorkTaskType,
|
||||
pub status: WorkQueueStatus,
|
||||
pub payload_json: String,
|
||||
#[sea_orm(nullable)]
|
||||
pub pipeline_id: Option<String>,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
#[sea_orm(nullable)]
|
||||
pub started_at: Option<chrono::NaiveDateTime>,
|
||||
#[sea_orm(nullable)]
|
||||
pub completed_at: Option<chrono::NaiveDateTime>,
|
||||
#[sea_orm(nullable)]
|
||||
pub error: Option<String>,
|
||||
pub retry_count: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in New Issue
Block a user