slowness due to the betaseries step, moving to shared task
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2s

This commit is contained in:
pierre geeraert
2026-07-04 13:53:44 +01:00
parent c9e66762df
commit 919065093d
2 changed files with 13 additions and 8 deletions
+11 -5
View File
@@ -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)
+2 -3
View File
@@ -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))