1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Moved medal calculation to doreah

This commit is contained in:
Krateng 2019-04-05 17:18:17 +02:00
parent 8dcc2766a5
commit 6516c2d108
3 changed files with 8 additions and 40 deletions

View File

@ -1,3 +1,4 @@
logging.logfolder = logs logging.logfolder = logs
settings.files = [ "settings/default.ini" , "settings/settings.ini" ] settings.files = [ "settings/default.ini" , "settings/settings.ini" ]
caching.folder = "images/cached/" caching.folder = "images/cached/"
regular.autostart = false

View File

@ -787,8 +787,8 @@ def build_db():
#loadCache() #loadCache()
#start regular tasks #start regular tasks
startpulse() update_medals()
scheduletest()

View File

@ -10,6 +10,7 @@ import itertools
from doreah import settings from doreah import settings
from doreah import caching from doreah import caching
from doreah.logging import log from doreah.logging import log
from doreah.regular import yearly, daily
@ -476,21 +477,12 @@ def resolveImage(artist=None,track=None):
## PULSE MAINTENANCE ## PULSE MAINTENANCE
##### #####
def startpulse():
# execute all actions for startup
# they will themselves trigger their next pass
yearly()
monthly()
daily()
@yearly
def update_medals():
def yearly():
#medals
from database import MEDALS, MEDALS_TRACKS, STAMPS, get_charts_artists, get_charts_tracks from database import MEDALS, MEDALS_TRACKS, STAMPS, get_charts_artists, get_charts_tracks
firstyear = datetime.datetime.utcfromtimestamp(STAMPS[0]).year firstyear = datetime.datetime.utcfromtimestamp(STAMPS[0]).year
@ -521,32 +513,7 @@ def yearly():
else: break else: break
@daily
# schedule for next year def scheduletest():
now = datetime.datetime.utcnow()
nextyear = datetime.datetime(now.year+1,1,1)
wait = nextyear.timestamp() - now.timestamp()
Timer(wait,yearly).start()
def monthly():
log("New month!",module="debug")
# schedule for next month
now = datetime.datetime.utcnow()
nextmonth = datetime.datetime(now.year,now.month + 1,1) if now.month != 12 else datetime.datetime(now.year+1,1,1)
wait = nextmonth.timestamp() - now.timestamp()
Timer(wait,monthly).start()
def daily():
log("New day!",module="debug") log("New day!",module="debug")
# schedule for tomorrow
now = datetime.datetime.utcnow()
nextday = datetime.datetime(now.year,now.month,now.day) + datetime.timedelta(days=1)
wait = nextday.timestamp() - now.timestamp()
Timer(wait,daily).start()