38 lines
960 B
Rust
38 lines
960 B
Rust
use crate::{DateTimeUtc, IssueId, RepoId, UserId};
|
|
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use super::PrStatus;
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "pull_request")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub repo: RepoId,
|
|
#[sea_orm(primary_key)]
|
|
pub number: i64,
|
|
pub issue: IssueId,
|
|
pub title: String,
|
|
pub body: Option<String>,
|
|
pub author: UserId,
|
|
pub base: String,
|
|
pub head: String,
|
|
pub status: String,
|
|
pub merged_by: Option<UserId>,
|
|
pub created_at: DateTimeUtc,
|
|
pub updated_at: DateTimeUtc,
|
|
pub merged_at: Option<DateTimeUtc>,
|
|
pub created_by_ai: bool,
|
|
}
|
|
|
|
impl Model {
|
|
pub fn status_enum(&self) -> Result<PrStatus, &'static str> {
|
|
self.status.parse()
|
|
}
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|