Skip to content
Clone
030e59e
57 lines 1.6 KB Rust
use db::issue::issue_event_line as event_entity;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use time::format_description::well_known::Rfc3339;
use utoipa::{IntoParams, ToSchema};
use uuid::Uuid;
fn fmt_ts(ts: OffsetDateTime) -> String {
ts.format(&Rfc3339).unwrap_or_default()
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct EventView {
pub id: Uuid,
pub issue_id: Option<Uuid>,
pub user_id: Uuid,
pub event_type: String,
pub comment_id: Option<Uuid>,
pub commit_sha: Option<String>,
pub old_title: Option<String>,
pub new_title: Option<String>,
pub old_ref: Option<String>,
pub new_ref: Option<String>,
pub content: Option<String>,
pub created_at: String,
}
impl From<event_entity::Model> for EventView {
fn from(m: event_entity::Model) -> Self {
Self {
id: m.id,
issue_id: m.issue_id,
user_id: m.user_id,
event_type: m.event_type,
comment_id: m.comment_id,
commit_sha: m.commit_sha,
old_title: m.old_title,
new_title: m.new_title,
old_ref: m.old_ref,
new_ref: m.new_ref,
content: m.content,
created_at: fmt_ts(m.created_at),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct EventPage {
pub items: Vec<EventView>,
pub total: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
pub struct ListEventQuery {
pub limit: Option<u64>,
pub offset: Option<u64>,
}