-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
75 lines (56 loc) · 1.76 KB
/
models.py
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
from __future__ import annotations
import datetime
import dataclasses
from typing import Dict, List, Tuple
@dataclasses.dataclass
class QueueItem:
date: datetime.date
users: Dict[str, User]
hours: List[Hour]
@dataclasses.dataclass
class User:
joined: datetime.datetime
last_seen: datetime.datetime
messages: int = 0
sum_text_size: int = 0
uwus: int = 0
@dataclasses.dataclass
class Month:
messages: int = 0
sum_text_size: int = 0
unique_users: set = dataclasses.field(default_factory=set)
@dataclasses.dataclass
class CompressedResult:
timespan: Tuple[datetime.datetime, datetime.datetime]
users: Dict[str, CompressedUser] = dataclasses.field(default_factory=dict)
hours: List[Hour] = dataclasses.field(default_factory=list)
months: Dict[int, List[Month]] = dataclasses.field(default_factory=dict)
@dataclasses.dataclass
class CompressedUser(User):
days_active: int = 0
@property
def avg_message_size(self):
return self.sum_text_size / self.messages
@dataclasses.dataclass
class Hour:
messages: int = 0
@dataclasses.dataclass
class CompressedMonth:
messages: int = 0
sum_text_size: int = 0
unique_users: int = 0
@dataclasses.dataclass
class Year:
messages: int = 0
sum_text_size: int = 0
unique_users: int = 0
@dataclasses.dataclass
class Result:
timespan: Tuple[datetime.datetime, datetime.datetime]
messages: int = 0
sum_text_size: int = 0
unique_users: int = 0
users: Dict[str, CompressedUser] = dataclasses.field(default_factory=dict)
hours: List[Hour] = dataclasses.field(default_factory=list)
months: Dict[int, List[CompressedMonth]] = dataclasses.field(default_factory=dict)
years: Dict[int, Year] = dataclasses.field(default_factory=dict)