1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
use derive_more::{Display, Error};
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize, PartialEq, Eq, Clone, Debug, Copy)]
#[serde(rename_all = "camelCase")]
pub enum ChartSpan {
    Day,
    Hour,
}

#[derive(Debug, Display, Error, Clone)]
#[display(fmt = "invalid chart span")]
pub struct ParseChartSpanError;

impl std::str::FromStr for ChartSpan {
    type Err = ParseChartSpanError;

    fn from_str(s: &str) -> Result<ChartSpan, Self::Err> {
        match s {
            "day" | "Day" => Ok(ChartSpan::Day),
            "hour" | "Hour" => Ok(ChartSpan::Hour),
            _ => Err(ParseChartSpanError),
        }
    }
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DriveChart {
    #[serde(alias = "totalFiles")]
    pub total_count: Vec<u64>,
    #[serde(alias = "totalUsage")]
    pub total_size: Vec<u64>,
    #[serde(alias = "incFiles")]
    pub inc_count: Vec<u64>,
    #[serde(alias = "incUsage")]
    pub inc_size: Vec<u64>,
    #[serde(alias = "decFiles")]
    pub dec_count: Vec<u64>,
    #[serde(alias = "decUsage")]
    pub dec_size: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct FederationChart {
    pub total: Vec<u64>,
    pub inc: Vec<u64>,
    pub dec: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ActiveUsersChart {
    pub count: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct HashtagChart {
    pub count: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct RequestsChart {
    pub failed: Vec<u64>,
    pub succeeded: Vec<u64>,
    pub received: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct NotesChart {
    pub total: Vec<u64>,
    pub inc: Vec<u64>,
    pub dec: Vec<u64>,
    pub diffs: NotesDiffsChart,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct NotesDiffsChart {
    pub normal: Vec<u64>,
    pub reply: Vec<u64>,
    pub renote: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct UsersChart {
    pub total: Vec<u64>,
    pub inc: Vec<u64>,
    pub dec: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct FollowingChart {
    pub total: Vec<u64>,
    pub inc: Vec<u64>,
    pub dec: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct FollowersChart {
    pub total: Vec<u64>,
    pub inc: Vec<u64>,
    pub dec: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct NetworkChart {
    pub incoming_requests: Vec<u64>,
    pub outgoing_requests: Vec<u64>,
    pub total_time: Vec<u64>,
    pub incoming_bytes: Vec<u64>,
    pub outgoing_bytes: Vec<u64>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ReactionsChart {
    pub count: Vec<u64>,
}