switched to uv and gitea-actions-based pipeline
All checks were successful
Build container / Build (pull_request) Successful in 43s
All checks were successful
Build container / Build (pull_request) Successful in 43s
This commit is contained in:
@@ -2,7 +2,7 @@ from peewee import *
|
||||
from pathlib import Path
|
||||
import re
|
||||
import os
|
||||
import datetime
|
||||
import socket
|
||||
|
||||
ID_MAPPINGS = {
|
||||
"Lia": 5603036217,
|
||||
@@ -11,9 +11,9 @@ ID_MAPPINGS = {
|
||||
ID_MAPPINGS_REV = dict((v, k) for k, v in ID_MAPPINGS.items())
|
||||
|
||||
RATING_MAPPING = {
|
||||
1: "😵",
|
||||
2: "☹️",
|
||||
3: "😐",
|
||||
1: "🙁",
|
||||
2: "😐",
|
||||
3: "🙂",
|
||||
4: "😃",
|
||||
5: "🥰"
|
||||
}
|
||||
@@ -21,6 +21,11 @@ RATING_MAPPING = {
|
||||
MEDIA_DIR = Path(os.getenv("MEDIA_DIR"))
|
||||
MEDIA_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# check if we are running on a cluster
|
||||
IS_PRODUCTION = os.getenv('KUBERNETES_SERVICE_HOST') is not None
|
||||
|
||||
|
||||
|
||||
db = DatabaseProxy()
|
||||
|
||||
class BaseModel(Model):
|
||||
@@ -37,11 +42,11 @@ class JournalEntry(BaseModel):
|
||||
media_path = TextField(null=True)
|
||||
last_shown = DateField(null=True)
|
||||
rating = IntegerField(null=True) # mapped by RATING_MAPPING
|
||||
|
||||
|
||||
@property
|
||||
def media(self):
|
||||
return Path(self.media_path).open('rb')
|
||||
|
||||
|
||||
def save_media(self, media: bytearray, file_name: str):
|
||||
ext = Path(file_name).suffix
|
||||
file_name = f"{self.date.isoformat()}-media{ext}"
|
||||
@@ -87,7 +92,7 @@ class JournalEntry(BaseModel):
|
||||
group_to_replace = match[0]
|
||||
new_text = new_text.replace(group_to_replace, f"<tg-spoiler>{group_to_replace}</tg-spoiler>")
|
||||
return new_text
|
||||
|
||||
|
||||
|
||||
def set_db(db_path):
|
||||
db.initialize(SqliteDatabase(db_path))
|
||||
|
Reference in New Issue
Block a user