1use memory_lol::model::Account;
2
3pub mod client;
4
5pub use client::Client;
6
7use chrono::NaiveDate;
8
9#[derive(Clone, Debug, Eq, Hash, PartialEq)]
10pub struct Observation {
11 pub screen_name: String,
12 pub range: Option<(NaiveDate, NaiveDate)>,
13}
14
15impl Observation {
16 pub fn new(screen_name: String, range: Option<(NaiveDate, NaiveDate)>) -> Self {
17 Self { screen_name, range }
18 }
19
20 pub fn from_account(account: &Account) -> Vec<Self> {
21 account
22 .screen_names
23 .iter()
24 .map(|(screen_name, dates)| {
25 let range = if let Some(dates) = dates {
26 if dates.is_empty() {
27 None
28 } else {
29 Some((dates[0], dates[dates.len() - 1]))
30 }
31 } else {
32 None
33 };
34
35 Self {
36 screen_name: screen_name.to_string(),
37 range,
38 }
39 })
40 .collect()
41 }
42}