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

@@ -4,13 +4,13 @@ from telegram.error import BadRequest
import logging
from datetime import time, timedelta, timezone, datetime, date
from peewee import fn
import models
CHAT_ID = os.getenv("CHAT_ID")
class SetChatPhotoJob():
def __init__(self, models, bot: ExtBot, job_queue):
self.models = models
def __init__(self, bot: ExtBot, job_queue):
self.bot = bot
self.logger = logging.getLogger(self.__class__.__name__)
@@ -26,9 +26,9 @@ class SetChatPhotoJob():
async def callback_photo(self, context):
# last_seen of memory must be older than 10 days in past or None
with self.models.db:
possible_photos = self.models.JournalEntry.select().where(
self.models.JournalEntry.media_path != None
with models.db:
possible_photos = models.JournalEntry.select().where(
models.JournalEntry.media_path != None
).order_by(fn.Random())
try:

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: