ChenyuRabbitLove commited on
Commit
d4ccbc6
1 Parent(s): 13cf790

feat: add mes player model for loading player data from google big query

Browse files
medias/partner1.png CHANGED

Git LFS Details

  • SHA256: 85cb487b4c8870638cfa347f8891906c0fae050fb781ff9bc2619204beec9f4f
  • Pointer size: 131 Bytes
  • Size of remote file: 324 kB
medias/partner2.png CHANGED

Git LFS Details

  • SHA256: 26d3d6879cb1af1bd124660a230939a6e5065f3531522cdcf55003bf7921968a
  • Pointer size: 131 Bytes
  • Size of remote file: 347 kB
medias/partner3.png CHANGED

Git LFS Details

  • SHA256: 7a410079f59506065da9303fa350b4ac574c9d33119d32d2639379ea8e2f99d1
  • Pointer size: 131 Bytes
  • Size of remote file: 341 kB
medias/partner4.png CHANGED

Git LFS Details

  • SHA256: 86e6045dc0df8f4345321b2e49ad09e4b81b84ad45c89843ab3ca805bab658dd
  • Pointer size: 131 Bytes
  • Size of remote file: 345 kB
utils/mes_player_model.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass, field
2
+ from typing import List, Dict, Union
3
+ from datetime import datetime, date
4
+
5
+ import pandas as pd
6
+
7
+
8
+ @dataclass
9
+ class Player:
10
+ player_backend_user_id: str
11
+ player_nickname: str = field(default=None)
12
+ player_group: int = field(default=None)
13
+ partners: List[str] = field(default_factory=list)
14
+ badges: List[str] = field(default_factory=list)
15
+ rewards_status: Union[str, Dict[str, Dict[str, Union[bool, str]]]] = field(
16
+ default_factory=dict
17
+ )
18
+ adventure_logs: List[str] = field(default_factory=list)
19
+ total_active_days: int = field(default=0)
20
+ total_gained_scores: int = field(default=0)
21
+ total_finished_contents: int = field(default=0)
22
+ created_at_date: datetime.date = field(default_factory=date.today)
23
+ updated_at_date: datetime.date = field(default_factory=date.today)
24
+
25
+
26
+ def __post_init__(self, available_achievements: List, init: bool):
27
+ self.badges = self.badges.tolist()
28
+ self.partners = self.partners.tolist()
29
+ self.adventure_logs = self.adventure_logs.tolist()
30
+ self.assign_weekly_partner()
31
+
32
+ @staticmethod
33
+ def from_series(series: pd.Series) -> "Player":
34
+ """
35
+ Creates a Player instance from a pandas Series.
36
+
37
+ Args:
38
+ series (pd.Series): A pandas Series with player attributes.
39
+
40
+ Returns:
41
+ Player: A Player instance.
42
+ """
43
+ data = series.copy()
44
+ return Player(**data)