-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.py
More file actions
31 lines (23 loc) · 879 Bytes
/
state.py
File metadata and controls
31 lines (23 loc) · 879 Bytes
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
"""
内存状态管理:存储最近一次 scheduled interview 的上下文。
每当有新的 Calendly 预约,会覆盖当前状态。
"""
from dataclasses import dataclass, field
from datetime import datetime
from typing import Optional
@dataclass
class InterviewUser:
name: str
email: str
scheduled_at: str # ISO 8601 格式,已转为北京时间字符串
calendly_event_uri: str
bq_data: dict = field(default_factory=dict) # BigQuery 拉到的用户行为数据
fetched_at: Optional[datetime] = None
# 全局单例,保存最新一次 scheduled interview
current_interview: Optional[InterviewUser] = None
def set_interview(user: InterviewUser) -> None:
global current_interview
user.fetched_at = datetime.utcnow()
current_interview = user
def get_interview() -> Optional[InterviewUser]:
return current_interview