Compare commits
No commits in common. "6f80bbc0be16d2b093f652a84337ad0d04872339" and "33bcbdd4622e755c9ebfbeeed4d32180bc746dc9" have entirely different histories.
6f80bbc0be
...
33bcbdd462
1 changed files with 4 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
"""Store bot state"""
|
"""Store bot state"""
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
from schema import Schema, Use, Optional
|
from schema import Schema, Use, Optional
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from typing import Protocol
|
from typing import Protocol
|
||||||
|
|
@ -243,20 +243,18 @@ class _State():
|
||||||
|
|
||||||
def get_history_timestamps(self, users: list[Member]) -> list[datetime]:
|
def get_history_timestamps(self, users: list[Member]) -> list[datetime]:
|
||||||
"""Grab all timestamps in the history"""
|
"""Grab all timestamps in the history"""
|
||||||
ids = [int(m.id) for m in users]
|
others = [m.id for m in users]
|
||||||
|
|
||||||
# Fetch all the interaction times in history
|
# Fetch all the interaction times in history
|
||||||
# But only for interactions in the given user group
|
# But only for interactions in the given user group
|
||||||
times = set()
|
times = set()
|
||||||
for data in (data for id, data in self._users.items() if id in ids):
|
for data in (data for id, data in self._users.items() if int(id) in others):
|
||||||
matches = data.get(_Key.MATCHES, {})
|
matches = data.get(_Key.MATCHES, {})
|
||||||
for ts in (ts for id, ts in matches.items() if id in ids):
|
for ts in (ts for id, ts in matches.items() if int(id) in others):
|
||||||
times.add(ts)
|
times.add(ts)
|
||||||
|
|
||||||
# Convert to datetimes and sort
|
# Convert to datetimes and sort
|
||||||
datetimes = [ts_to_datetime(ts) for ts in times]
|
datetimes = [ts_to_datetime(ts) for ts in times]
|
||||||
# Remove any entries older than 6 months ago
|
|
||||||
datetimes = [t for t in datetimes if t >= datetime.now() - timedelta(months=3)]
|
|
||||||
datetimes.sort()
|
datetimes.sort()
|
||||||
return datetimes
|
return datetimes
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue