backend/model/dto/
timeline.rs1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4use typeshare::typeshare;
5use utoipa::{IntoParams, ToSchema};
6
7#[typeshare]
9#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema, PartialEq, Eq)]
10#[serde(rename_all = "camelCase")]
11pub struct TimelineEntryDto {
12 pub additions: i32,
13 pub removals: i32,
14}
15
16#[typeshare]
18#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, PartialEq, Eq)]
19#[serde(rename_all = "camelCase")]
20pub struct TimelineDto {
21 #[schema(example = "{ \"2020\": { \"additions\": 7, \"removals\": 7 } }")]
22 pub years: HashMap<String, TimelineEntryDto>,
23 #[schema(example = "{ \"2020-01\": { \"additions\": 7, \"removals\": 7 } }")]
24 pub months: HashMap<String, TimelineEntryDto>,
25 #[schema(
26 example = "{ \"2020-01-01\": { \"additions\": 3, \"removals\": 2 }, \"2020-01-05\": { \"additions\": 4, \"removals\": 5 } }"
27 )]
28 pub dates: HashMap<String, TimelineEntryDto>,
29}
30
31#[typeshare]
33#[derive(Debug, Deserialize, IntoParams)]
34#[serde(rename_all = "camelCase")]
35pub struct TimelineParameters {
36 pub start: NaiveDate,
38 pub end: NaiveDate,
40}