-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
75 lines (52 loc) · 1.27 KB
/
model.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 dataclasses import dataclass
from pydantic import BaseModel
class Cursor(BaseModel):
current: str | None
next: str | None
class Metadata(BaseModel):
count: int
cursor: int | Cursor
class YearLevel(BaseModel):
id: int
name: str
class Student(BaseModel):
id: int
yearLevel: YearLevel
isDeleted: bool
fullName: str
externalId: str | None
username: str
enabled: bool
title: str
firstName: str
lastName: str
preferredName: str | None
class Users(BaseModel):
data: list[Student]
metadata: Metadata
class Badge(BaseModel):
id: int
name: str
class AchievementBadge(BaseModel):
id: int
badge: Badge
class Achievement(BaseModel):
discriminator: str
object: AchievementBadge
date: str # The date as a RFC3339 string
class Achievements(BaseModel):
data: list[Achievement]
metadata: Metadata
@dataclass
class ProcessedStudent:
schoolboxId: int
externalId: int
fullName: str
firstName: str
lastName: str
badges: dict[str, int]
def add_badge(self, name: str, count: int = 1) -> None:
badge = self.badges.get(name, 0)
self.badges[name] = badge + count
def get_badge(self, name: str) -> int:
return self.badges.get(name, 0)