cleanup the model layout
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-11-17 22:53:06 +01:00
parent 9eb7f5bb77
commit 49df5a4495
7 changed files with 37 additions and 42 deletions

View File

@@ -2,10 +2,10 @@ from datetime import time, timedelta, timezone, datetime, date
import os
from peewee import fn
import logging
import models
class RandomMemoryJob():
def __init__(self, models, bot, job_queue):
self.models = models
def __init__(self, bot, job_queue):
self.bot = bot
self.logger = logging.getLogger(self.__class__.__name__)
@@ -23,10 +23,10 @@ class RandomMemoryJob():
async def callback_memory(self, context):
# last_seen of memory must be older than 10 days in past or None
with self.models.db:
possible_entries = self.models.JournalEntry.select().where(
(self.models.JournalEntry.last_shown <= datetime.today().date() - timedelta(days=self.min_age)) | \
(self.models.JournalEntry.last_shown == None)
with models.db:
possible_entries = models.JournalEntry.select().where(
(models.JournalEntry.last_shown <= datetime.today().date() - timedelta(days=self.min_age)) | \
(models.JournalEntry.last_shown == None)
).order_by(fn.Random())
try: