fix: sync GitHub issue state for org bounty pages#221
Open
trasnake87 wants to merge 1 commit intoalgora-io:mainfrom
Open
fix: sync GitHub issue state for org bounty pages#221trasnake87 wants to merge 1 commit intoalgora-io:mainfrom
trasnake87 wants to merge 1 commit intoalgora-io:mainfrom
Conversation
Org bounty pages (/org/bounties) showed stale bounties as "open" with "0 claims" even when the linked GitHub issues had been closed or had merged PRs. The main /bounties page was unaffected because its visibility filter (featured orgs only) happened to exclude orgs with stale webhook data. Root cause: when GitHub webhooks are missed or not configured for a repo, the ticket.state field in the database stays at its default (:open) even after the GitHub issue is closed. The query correctly filters by ticket state, but the state is never updated. Fix: add an Oban background job (SyncBountyTickets) that refreshes ticket state from the GitHub API when an org bounty page is visited. The job is deduplicated to run at most once per hour per org, so repeated page loads don't spam the API. It uses the existing Workspace.update_ticket_from_github/4 function which already handles syncing issue state, closed_at, and merged_at fields. Also include ticket.state in the bounty list_bounties_with select so the UI has access to the current ticket state for display purposes. Fixes algora-io#213
Author
|
Friendly ping — this is ready for review whenever you get a chance. Happy to address any feedback. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Fix org bounty pages (
/:org/bounties) showing stale bounties as "open" with "0 claims" when the linked GitHub issues have been closed, PRs merged, or/claimcommands posted.Root cause
When GitHub webhooks are missed or not configured for a repo,
ticket.statestays at its default (:open) in the database even after the GitHub issue is closed. The bounty query correctly filters byt.state == :open(line 1218 ofbounties.ex), but the state is never updated for repos without reliable webhook delivery.The main
/bountiespage appeared unaffected because its visibility filter (o.featured == true) happens to exclude orgs with stale webhook data — not because it handles state differently.Fix
Background sync job (
SyncBountyTickets): An Oban worker that fetches current GitHub issue state for all open bounties belonging to an org. Enqueued when an org bounty page is visited, deduplicated to run at most once per hour per org to avoid API spam. Uses the existingWorkspace.update_ticket_from_github/4which already handles syncingstate,closed_at, andmerged_at.Include
ticket.statein select: Addedstate: t.stateto the bounty query's select map so the UI has access to the current ticket state for display purposes.How it works
Proof
--warnings-as-errorsChecklist
jobs/directories,Github.TokenPoolfor API tokens)Fixes #213
/claim #213