-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
16 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
-- Add new job to queue | ||
-- :name add_job :insert | ||
-- Add new job to queue | ||
INSERT INTO job (job_type, job_object, data) | ||
VALUES (:job_type, :job_object, :data) | ||
ON CONFLICT (job_type, job_object) | ||
DO NOTHING; | ||
|
||
-- Quick check if there are pending jobs | ||
-- :name has_jobs :one | ||
-- Quick check if there are pending jobs | ||
SELECT EXISTS (SELECT * FROM job LIMIT 1) | ||
|
||
-- :name get_job :one | ||
-- Get a random job from the queue to work on | ||
-- This selects jobs randomly to avoid bias or generation loops | ||
-- :name get_job :one | ||
SELECT * FROM job ORDER BY random() LIMIT 1 | ||
|
||
-- Mark that a job has failed, and so its attempt count is incremented | ||
-- :name fail_job :affected | ||
-- Mark that a job has failed, and so its attempt count is incremented | ||
UPDATE job | ||
SET attempts = attempts + 1 | ||
WHERE job_id = :job_id | ||
|
||
-- Delete job from queue, either because it's finished or failed | ||
-- :name delete_job :affected | ||
-- Delete job from queue, either because it's finished or failed | ||
DELETE FROM job | ||
WHERE job_id = :job_id; | ||
|
||
-- Add job to dead letter queue | ||
-- :name add_dead_job :insert | ||
-- Add job to dead letter queue | ||
INSERT INTO job_dead (job_id, job_type, job_object, data) | ||
VALUES (:job_id, :job_type, :job_object, :data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
-- Adds a page | ||
-- :name add_page :insert | ||
-- Adds a page | ||
INSERT INTO page (site_slug, page_slug, page_id, page_category_id) | ||
VALUES (:site_slug, :page_slug, :page_id, :page_category_id); | ||
|
||
-- Marks a page as deleted | ||
-- :name delete_page :affected | ||
-- Marks a page as deleted | ||
UPDATE page SET deleted_at = now() | ||
WHERE site_slug = :site_slug | ||
AND page_slug = :page_slug; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
-- Adds or updates a site | ||
-- :name add_site :insert | ||
-- Adds or updates a site | ||
INSERT INTO site (site_slug, wikidot_id, home_slug, name, tagline, language) | ||
VALUES (:site_slug, :site_id, :home_slug, :name, :tagline, :language) | ||
ON CONFLICT (site_slug) | ||
DO UPDATE | ||
SET home_slug = :home_slug, name = :name, tagline = :tagline, language = :language; | ||
|
||
-- Gets site by slug | ||
-- :name get_site :one | ||
-- Gets site by slug | ||
SELECT * FROM site | ||
WHERE site_slug = :slug; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-- Sets a user's avatar after uploading to S3 | ||
-- :name add_user_avatar :affected | ||
-- Sets a user's avatar after uploading to S3 | ||
UPDATE "user" | ||
SET avatar = :hash | ||
WHERE wikidot_id = :user_id; |