|
|
|
@ -23,11 +23,12 @@ class Community:
|
|
|
|
|
name: str = '' |
|
|
|
|
members: typing.List[int] = field(default_factory=list) |
|
|
|
|
pool: typing.List[int] = field(default_factory=list) # [user_id] |
|
|
|
|
polled: typing.Dict[int, date] = field(default_factory=dict) # Days since the user was asked |
|
|
|
|
polled: typing.Dict[int, date] = field(default_factory=dict) # Days since the user was asked |
|
|
|
|
scheduled_meetings: typing.List[typing.Tuple[int, int, date]] = field( |
|
|
|
|
default_factory=list) # (user_id_1, user_id_2, meeting date) |
|
|
|
|
archived_meetings: typing.List[typing.Tuple[int, int, date]] = field(default_factory=list) |
|
|
|
|
default_answers: typing.Dict[int, bool] = field(default_factory=dict) # Last answers |
|
|
|
|
default_answers: typing.Dict[int, bool] = field(default_factory=dict) # Last answers |
|
|
|
|
task_last_timestamps: typing.Dict[str, date] = field(default_factory=dict) # {'poll': ..., 'scheduling': ...} |
|
|
|
|
start_timestamp: int = field(default_factory=lambda: int(time.time())) |
|
|
|
|
|
|
|
|
|
def dict(self) -> dict: |
|
|
|
@ -36,6 +37,8 @@ class Community:
|
|
|
|
|
data['default_answers'] = {str(k): self.default_answers[k] for k in self.default_answers} |
|
|
|
|
data['scheduled_meetings'] = [(l, m, r.toordinal()) for l, m, r in self.scheduled_meetings] |
|
|
|
|
data['archived_meetings'] = [(l, m, r.toordinal()) for l, m, r in self.archived_meetings] |
|
|
|
|
data['task_last_timestamps'] = {str(k): self.task_last_timestamps[k].toordinal() for k in |
|
|
|
|
self.task_last_timestamps} |
|
|
|
|
return data |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@ -47,6 +50,8 @@ class Community:
|
|
|
|
|
self = cls(**data_) |
|
|
|
|
self.polled = {int(k): convert_to_date(self.polled[k]) for k in self.polled} |
|
|
|
|
self.default_answers = {int(k): self.default_answers[k] for k in self.default_answers} |
|
|
|
|
self.task_last_timestamps = {k: convert_to_date(self.task_last_timestamps[k]) for k in |
|
|
|
|
self.task_last_timestamps} |
|
|
|
|
self.scheduled_meetings = [(int(l), int(m), convert_to_date(r)) for l, m, r in self.scheduled_meetings] |
|
|
|
|
self.archived_meetings = [(int(l), int(m), convert_to_date(r)) for l, m, r in self.archived_meetings] |
|
|
|
|
return self |
|
|
|
@ -98,7 +103,7 @@ class Community:
|
|
|
|
|
for l, m, r in self.scheduled_meetings) |
|
|
|
|
|
|
|
|
|
def schedule_meetings(self): |
|
|
|
|
random.shuffle(self.pool) # It's called RandomTea for a reason |
|
|
|
|
random.shuffle(self.pool) # It's called RandomTea for a reason |
|
|
|
|
today = date.today() |
|
|
|
|
while len(self.pool) > 1: |
|
|
|
|
user_id_1 = self.pool.pop() |
|
|
|
|