Skip to content

Commit

Permalink
Abort duplicate jobs in the job queue
Browse files Browse the repository at this point in the history
  • Loading branch information
anishTP committed Nov 7, 2023
1 parent 0bdcbfb commit 6c698d2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions funnel/views/thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,26 @@
from flask import render_template
from html2image import Html2Image

from .. import rq
from ..models import Project, db
from ..signals import project_data_change
from .jobs import rqjob


@project_data_change.connect
def redo_project_preview_image(project: Project) -> None:
render_project_preview_image.queue(project_id=project.id)
render_project_preview_image.queue(project_id=project.id, job_id=project.id)


@rqjob()
def render_project_preview_image(project_id: int) -> None:
def render_project_preview_image(project_id: int, job_id: str) -> None:
"""Generate a project preview image."""

task_queue = rq.get_queue()
for job in task_queue.jobs:
if job.get_id() is job_id:
return

project = Project.query.get(project_id)
if project is None:
return
Expand Down

0 comments on commit 6c698d2

Please sign in to comment.