Skip to main content

tango_core/entities/
channel.rs

1use sea_orm::entity::prelude::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
5#[sea_orm(table_name = "channels")]
6pub struct Model {
7    #[sea_orm(primary_key, auto_increment = false)]
8    pub id: String,
9    pub handle: Option<String>,
10    pub description: Option<String>,
11    pub uploads_playlist_id: Option<String>,
12    pub title: Option<String>,
13    pub thumbnail_url: Option<String>,
14    #[sea_orm(column_type = "JsonBinary", nullable)]
15    pub thumbnails: Option<serde_json::Value>,
16    pub subscriber_count: Option<i64>,
17    pub video_count: Option<i64>,
18    pub view_count: Option<i64>,
19    pub hidden_subscriber_count: Option<bool>,
20    pub stats_refreshed_at: Option<DateTimeWithTimeZone>,
21    pub created_at: DateTimeWithTimeZone,
22    pub updated_at: DateTimeWithTimeZone,
23    pub last_full_sync_at: Option<DateTimeWithTimeZone>,
24    /// Identity of the title filter used by the run that set
25    /// `last_full_sync_at`; `all` for an unfiltered one. The incremental
26    /// boundary arms only when this matches the filter in use now: a harvest
27    /// that kept a subset has not stored what it excluded.
28    pub last_full_sync_filter: Option<String>,
29    pub latest_published_at: Option<DateTimeWithTimeZone>,
30    /// playlistItems page token an interrupted v3 harvest should resume from.
31    /// NULL means there is nothing outstanding.
32    pub harvest_page_token: Option<String>,
33    /// Product-surface gate: whether the channel is surfaced in the product.
34    /// `draft` (default) means harvested but unpublished; `published` means
35    /// visible through the product's public endpoints.
36    #[sea_orm(column_type = "Text")]
37    pub status: String,
38    /// Whether channel membership is open for joining.
39    pub membership_open: bool,
40    /// External links shown on the channel page (`[{type, href, label?}]`).
41    #[sea_orm(column_type = "JsonBinary", nullable)]
42    pub links: Option<serde_json::Value>,
43}
44
45#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
46pub enum Relation {
47    #[sea_orm(has_many = "super::video::Entity")]
48    Video,
49}
50
51impl Related<super::video::Entity> for Entity {
52    fn to() -> RelationDef {
53        Relation::Video.def() // Changed from .into_ref() to .def()
54    }
55}
56
57impl ActiveModelBehavior for ActiveModel {}