mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(coderd): refactors github pr sync functionality (#22715)
- Adds `_API_BASE_URL` to `CODER_EXTERNAL_AUTH_CONFIG_` - Extracts and refactors existing GitHub PR sync logic to new packages `coderd/gitsync` and `coderd/externalauth/gitprovider` - Associated wiring and tests Created using Opus 4.6
This commit is contained in:
@@ -448,3 +448,52 @@ LIMIT
|
||||
|
||||
-- name: GetChatByIDForUpdate :one
|
||||
SELECT * FROM chats WHERE id = @id::uuid FOR UPDATE;
|
||||
|
||||
-- name: AcquireStaleChatDiffStatuses :many
|
||||
WITH acquired AS (
|
||||
UPDATE
|
||||
chat_diff_statuses
|
||||
SET
|
||||
-- Claim for 5 minutes. The worker sets the real stale_at
|
||||
-- after refresh. If the worker crashes, rows become eligible
|
||||
-- again after this interval.
|
||||
stale_at = NOW() + INTERVAL '5 minutes',
|
||||
updated_at = NOW()
|
||||
WHERE
|
||||
chat_id IN (
|
||||
SELECT
|
||||
cds.chat_id
|
||||
FROM
|
||||
chat_diff_statuses cds
|
||||
INNER JOIN
|
||||
chats c ON c.id = cds.chat_id
|
||||
WHERE
|
||||
cds.stale_at <= NOW()
|
||||
AND cds.git_remote_origin != ''
|
||||
AND cds.git_branch != ''
|
||||
AND c.archived = FALSE
|
||||
ORDER BY
|
||||
cds.stale_at ASC
|
||||
FOR UPDATE OF cds
|
||||
SKIP LOCKED
|
||||
LIMIT
|
||||
@limit_val::int
|
||||
)
|
||||
RETURNING *
|
||||
)
|
||||
SELECT
|
||||
acquired.*,
|
||||
c.owner_id
|
||||
FROM
|
||||
acquired
|
||||
INNER JOIN
|
||||
chats c ON c.id = acquired.chat_id;
|
||||
|
||||
-- name: BackoffChatDiffStatus :exec
|
||||
UPDATE
|
||||
chat_diff_statuses
|
||||
SET
|
||||
stale_at = @stale_at::timestamptz,
|
||||
updated_at = NOW()
|
||||
WHERE
|
||||
chat_id = @chat_id::uuid;
|
||||
|
||||
Reference in New Issue
Block a user