pinakes-server: split dto module into submodules
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I1e9421d79010813992feb2b26c44d6796a6a6964
This commit is contained in:
parent
e66a2231b7
commit
d77e5b9f2f
21 changed files with 1530 additions and 1443 deletions
34
crates/pinakes-server/src/dto/analytics.rs
Normal file
34
crates/pinakes-server/src/dto/analytics.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct UsageEventResponse {
|
||||
pub id: String,
|
||||
pub media_id: Option<String>,
|
||||
pub user_id: Option<String>,
|
||||
pub event_type: String,
|
||||
pub timestamp: DateTime<Utc>,
|
||||
pub duration_secs: Option<f64>,
|
||||
}
|
||||
|
||||
impl From<pinakes_core::analytics::UsageEvent> for UsageEventResponse {
|
||||
fn from(e: pinakes_core::analytics::UsageEvent) -> Self {
|
||||
Self {
|
||||
id: e.id.to_string(),
|
||||
media_id: e.media_id.map(|m| m.0.to_string()),
|
||||
user_id: e.user_id.map(|u| u.0.to_string()),
|
||||
event_type: e.event_type.to_string(),
|
||||
timestamp: e.timestamp,
|
||||
duration_secs: e.duration_secs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct RecordUsageEventRequest {
|
||||
pub media_id: Option<Uuid>,
|
||||
pub event_type: String,
|
||||
pub duration_secs: Option<f64>,
|
||||
pub context: Option<serde_json::Value>,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue