slowness due to the betaseries step, moving to shared task
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from django.db.models import Count
|
||||
from django.core.exceptions import MultipleObjectsReturned
|
||||
from celery.worker.state import active_requests
|
||||
from celery import shared_task
|
||||
from requests.compat import str
|
||||
from apps.betaserie.utils import betaserieUtils
|
||||
from .models import simpsons_data_object
|
||||
@@ -9,11 +10,16 @@ betaserie = betaserieUtils()
|
||||
|
||||
simpsons_id = 12
|
||||
|
||||
def mark_episode_watched(season,episode,action):
|
||||
|
||||
print("season_number: "+str(season))
|
||||
print("episode_number: "+str(episode))
|
||||
|
||||
@shared_task()
|
||||
def mark_episode_watched(season,episode,action,verbose=False):
|
||||
#mark episode as seen in DB
|
||||
simpsons_data_object.filter(season=season, episode=episode).values('seen').update(seen=True)
|
||||
|
||||
|
||||
if verbose : print("season_number: "+str(season))
|
||||
if verbose : print("episode_number: "+str(episode))
|
||||
|
||||
#mark episode as seen in betaserie
|
||||
episode_number = "S"+str(season)+"E"+str(episode)
|
||||
|
||||
episode_id = betaserie.identify_episode(simpsons_id,episode_number)
|
||||
|
||||
@@ -36,10 +36,9 @@ def episode_generator(request):
|
||||
#Set episode as seen
|
||||
# It will still update an already seem episode but it works and I'm lazy
|
||||
|
||||
simpsons_data_object.filter(season=random_seasons, episode=random_episode).values('seen').update(seen=True)
|
||||
|
||||
|
||||
#Mark episode as seen on betaseries
|
||||
mark_episode_watched(random_seasons,random_episode,"watched")
|
||||
mark_episode_watched.delay(random_seasons,random_episode,"watched")
|
||||
|
||||
return redirect(str(random_url))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user