Compare commits
9 commits
e8dc691c0b
...
e410529756
| Author | SHA1 | Date | |
|---|---|---|---|
| e410529756 | |||
| 72f9b01183 | |||
| 4a0f2d95c4 | |||
| 6f80bbc0be | |||
| 33bcbdd462 | |||
| 3675430390 | |||
| a89957f891 | |||
| 3bc363648c | |||
| 47eca14fd8 |
2 changed files with 9 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
"""Store bot state"""
|
"""Store bot state"""
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
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,18 +243,20 @@ 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"""
|
||||||
others = [m.id for m in users]
|
ids = [int(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 int(id) in others):
|
for data in (data for id, data in self._users.items() if id in ids):
|
||||||
matches = data.get(_Key.MATCHES, {})
|
matches = data.get(_Key.MATCHES, {})
|
||||||
for ts in (ts for id, ts in matches.items() if int(id) in others):
|
for ts in (ts for id, ts in matches.items() if id in ids):
|
||||||
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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
coverage==7.6.10
|
coverage==7.12.0
|
||||||
discord.py==2.6.4
|
discord.py==2.6.4
|
||||||
dpytest==0.7.0
|
dpytest==0.7.0
|
||||||
flake8==7.1.1
|
flake8==7.1.1
|
||||||
pytest==8.3.3
|
pytest==8.4.2
|
||||||
pytest-asyncio==0.25.2
|
pytest-asyncio==0.25.2
|
||||||
pytest-cov==5.0.0
|
pytest-cov==5.0.0
|
||||||
schema==0.7.7
|
schema==0.7.8
|
||||||
Loading…
Add table
Add a link
Reference in a new issue