Initial commit

This commit is contained in:
Connor Johnstone
2026-03-17 14:14:46 -04:00
commit 305ddff278
27 changed files with 1897 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Text")]
pub enum DownloadStatus {
#[sea_orm(string_value = "pending")]
Pending,
#[sea_orm(string_value = "downloading")]
Downloading,
#[sea_orm(string_value = "completed")]
Completed,
#[sea_orm(string_value = "failed")]
Failed,
#[sea_orm(string_value = "cancelled")]
Cancelled,
}
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "download_queue")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(nullable)]
pub wanted_item_id: Option<i32>,
pub query: String,
#[sea_orm(nullable)]
pub source_url: Option<String>,
pub source_backend: String,
pub status: DownloadStatus,
#[sea_orm(nullable)]
pub error_message: Option<String>,
pub retry_count: i32,
pub created_at: chrono::NaiveDateTime,
pub updated_at: chrono::NaiveDateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::wanted_item::Entity",
from = "Column::WantedItemId",
to = "super::wanted_item::Column::Id",
on_delete = "Cascade"
)]
WantedItem,
}
impl Related<super::wanted_item::Entity> for Entity {
fn to() -> RelationDef {
Relation::WantedItem.def()
}
}
impl ActiveModelBehavior for ActiveModel {}