use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
/// The lameness filter held a post for review ([`crate::lameness`]).
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "post_holds")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub post_id: Uuid,
/// The author (strikes are theirs).
pub user_id: Uuid,
/// What tripped, one per line.
pub reasons: String,
/// Every measurement, JSON.
pub scores: String,
pub created_at: DateTimeWithTimeZone,
pub resolved_at: Option<DateTimeWithTimeZone>,
pub resolved_by_id: Option<Uuid>,
/// `dismissed`, `upheld` (a strike) or `withdrawn`.
pub resolution: Option<String>,
pub strike_cleared_at: Option<DateTimeWithTimeZone>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::posts::Entity",
from = "Column::PostId",
to = "super::posts::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Posts,
}
impl Related<super::posts::Entity> for Entity {
fn to() -> RelationDef {
Relation::Posts.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
impl Model {
pub fn reason_list(&self) -> Vec<String> {
self.reasons.lines().map(str::to_string).filter(|l| !l.is_empty()).collect()
}
}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions running · Badges · Packages
⭐
Log in to mark this repository.
1.4 KiB · text
History
6e34613