mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2025-01-30 14:58:42 +00:00
♻️ Refactor action log init pairs
This commit is contained in:
parent
85879adc6c
commit
677315e06b
@ -32,15 +32,16 @@ class ActionLogAnalyse(DateUtils):
|
||||
|
||||
@staticmethod
|
||||
def init_pair(data: List[ZZZSelfHelpActionLog]) -> List[ActionLogPair]:
|
||||
# 确保第一个数据为登入,最后一条数据为登出
|
||||
pairs = []
|
||||
start = None
|
||||
for d in data:
|
||||
if start:
|
||||
if d.reason == ZZZSelfHelpActionLogReason.LOG_OUT:
|
||||
pairs.append(ActionLogPair(start=start, end=d))
|
||||
start = None
|
||||
elif d.reason == ZZZSelfHelpActionLogReason.LOG_IN:
|
||||
start = d
|
||||
for i in data:
|
||||
if i.status == 1 and not start:
|
||||
start = i
|
||||
elif i.status == 0 and start:
|
||||
end = i
|
||||
pairs.append(ActionLogPair(start=start, end=end))
|
||||
start = None
|
||||
return pairs
|
||||
|
||||
def get_this_week_duration(self) -> int:
|
||||
|
Loading…
Reference in New Issue
Block a user