Mensa-Fix

This commit is contained in:
2024-01-22 18:10:41 +01:00
parent 3b8cf7e53d
commit 4260ca0e92
2 changed files with 7 additions and 5 deletions

View File

@ -144,7 +144,6 @@ def getPruefung(url):
col = [e.text.strip() for e in cols]
if len(col) == 6 and len(col[3]) <= 13:
if len(col[3]) != 0:
print (col)
ret += [col[0] + ": " + col[3][:3]]
if ret[-1][0] == ':':
ret[-1] = "Gesamt" + ret[-1]

View File

@ -40,7 +40,6 @@ def getMealsFromAPI(day: str, dbentry: bool = False):
response = response.content
jres = json.loads(response.decode("utf-8"))
essen = []
try:
num = len(jres["data"][0]["lines"])
for i in range(num):
@ -67,7 +66,7 @@ def getMealsFromAPI(day: str, dbentry: bool = False):
essen += [name]
if dbentry:
mid = int(time.time()*1000) % 100000
mid = int(time.time() * 1000) % 100000
neu = Meals(date=day, name=name, id=mid, vegan=vegan, vegetarian=veget, schwein=schwein)
db.session.add(neu)
db.session.commit()
@ -99,11 +98,15 @@ def formatDay(day: datetime):
:param day:
:return str:
"""
if day.month < 10:
mon = "0" + str(day.month)
else:
mon = str(day.month)
if day.day < 10:
tag = "0" + str(day.day)
else:
tag = str(day.day)
day = str(day.year) + "-" + str(day.month) + "-" + tag
day = str(day.year) + "-" + mon + "-" + tag
return day
@ -128,7 +131,7 @@ def refreshMeals():
dbnames = []
for m in dbmeals:
dbnames += [m.name]
if set (dbnames) != set(apinames) and nomeal not in apinames:
if set(dbnames) != set(apinames) and nomeal not in apinames:
for n in dbnames:
db.session.delete(Meals.query.filter_by(date=i, name=n).first())
db.session.commit()