Skip to content

Commit

Permalink
Don't add index-site-members job if already queued.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Jan 22, 2024
1 parent 2ad2386 commit 677c64c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions queries/site_member.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ INSERT INTO site_member (user_id, site_id, joined_at)
VALUES (:user_id, :site_id, :joined_at)
ON CONFLICT (user_id, site_id)
DO NOTHING;

-- :name get_site_member_job :one
SELECT * FROM job
WHERE job_type = 'index-site-members'
AND data ->> 'site_slug' = :site_slug;
6 changes: 6 additions & 0 deletions yellowstone/job/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def index_site_members(self, data: SiteMemberJob) -> None:
self.add_raw(JobType.INDEX_SITE_MEMBERS, cast(Json, data))

def index_site_members_continue(self, site_slug: str) -> None:
# Only queue if there already isn't a member index job for the site
job = self.database.get_site_member_job(site_slug=site_slug)
if job is not None:
logger.debug("Found an index-site-members job for this site")
return

# Reads the last member page, and continues from there
offset = self.database.get_last_number_offset(site_slug=site_slug)
self.index_site_members(
Expand Down

0 comments on commit 677c64c

Please sign in to comment.