statistics can load logs from archives

This commit is contained in:
bkfox
2020-05-31 20:07:37 +02:00
parent 4cda6d42e4
commit 09d0cab206
4 changed files with 15 additions and 3 deletions

View File

@ -154,9 +154,14 @@ class Log(models.Model):
@classmethod
def merge_diffusions(cls, logs, diffs, count=None):
"""
Merge logs and diffusions together. `logs` can either be a queryset
or a list ordered by `Log.date`.
"""
# TODO: limit count
# FIXME: log may be iterable (in stats view)
logs = list(logs.order_by('-date'))
if isinstance(logs, models.QuerySet):
logs = list(logs.order_by('-date'))
diffs = deque(diffs.on_air().before().order_by('-start'))
object_list = []
@ -171,7 +176,7 @@ class Log(models.Model):
diff = diffs.popleft()
# - takes all logs after diff
# - takes all logs after diff start
index = next((i for i, v in enumerate(logs)
if v.date <= diff.end), len(logs))
if index is not None and index > 0: