Spaces:
Running
Running
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 +0 -0
- medias/partner2.png +0 -0
- medias/partner3.png +0 -0
- medias/partner4.png +0 -0
- utils/mes_player_model.py +44 -0
medias/partner1.png
CHANGED
Git LFS Details
|
medias/partner2.png
CHANGED
Git LFS Details
|
medias/partner3.png
CHANGED
Git LFS Details
|
medias/partner4.png
CHANGED
Git LFS Details
|
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)
|