feature: group the Forgejo issue-link confirmation comment per issue instead of per linked spec #36

Merged
Gilles merged 2 commits from feature/group-issue-link-comments into master 2026-11-01 19:26:03 +00:00
Owner

Closes #35

sync_confirmation_comment used to post/edit one comment per SpecVersionIssueLink (the comment id tracked on the link itself via confirmation_comment_id), so an issue linked to several specs got spammed with one "🔗 Spec liée" comment per spec.

Changes

  • New ForgejoIssueComment model (apps/specs/models.py), tracking a single comment id per (repo_full_name, issue_number) pair, replacing the per-link confirmation_comment_id field (removed). Migration 0013.
  • sync_confirmation_comment(repo_full_name, issue_number) (new signature) now gathers every SpecVersionIssueLink on that issue and builds one grouped "🔗 Specs liées" comment, edited in place afterward, never reposted.
  • All five dispatch call sites updated to pass (repo_full_name, issue_number):
    • SpecViewSet.create_issue, SpecVersionIssueLinkViewSet.perform_create (single-link sites)
    • ForgejoIssueWebhookView.post, poll_stale_issue_links -- deduped to one dispatch per (repo, issue) pair, since several changed/created links can share a pair in the same sync and dispatching once per link would race two task runs to create the same ForgejoIssueComment row
    • apps.exports.tasks.generate_pdf_export's PDF-export-completion hook (an extra call site found while grepping, not called out in the original report, but it dispatched the old per-link signature too)
  • apps/specs/admin.py: dropped confirmation_comment_id from the readonly fields, registered a ForgejoIssueCommentAdmin following the same convention as ForgejoRepoWebhookAdmin.
  • Tests: updated every assertion on the old per-link signature/field across apps/specs/test_issue_sync.py, apps/specs/test_issue_links.py, and apps/exports/tests.py; added tests for (a) two links on the same issue grouping into one create_comment call containing both specs, (b) a no-op when the (repo, issue) pair has zero links, and (c) dedup at the webhook and poll call sites (two links detected/changed on the same issue dispatch exactly once).

Test plan

  • pytest apps/specs apps/exports -- 175 passed locally.
  • pytest apps (full suite) -- 210 passed locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_013EeueXTWCT4Y6EbeideZcm

Closes #35 `sync_confirmation_comment` used to post/edit one comment per `SpecVersionIssueLink` (the comment id tracked on the link itself via `confirmation_comment_id`), so an issue linked to several specs got spammed with one "🔗 Spec liée" comment per spec. ## Changes - New `ForgejoIssueComment` model (`apps/specs/models.py`), tracking a single comment id per `(repo_full_name, issue_number)` pair, replacing the per-link `confirmation_comment_id` field (removed). Migration `0013`. - `sync_confirmation_comment(repo_full_name, issue_number)` (new signature) now gathers every `SpecVersionIssueLink` on that issue and builds one grouped "🔗 Specs liées" comment, edited in place afterward, never reposted. - All five dispatch call sites updated to pass `(repo_full_name, issue_number)`: - `SpecViewSet.create_issue`, `SpecVersionIssueLinkViewSet.perform_create` (single-link sites) - `ForgejoIssueWebhookView.post`, `poll_stale_issue_links` -- deduped to one dispatch per `(repo, issue)` pair, since several changed/created links can share a pair in the same sync and dispatching once per link would race two task runs to create the same `ForgejoIssueComment` row - `apps.exports.tasks.generate_pdf_export`'s PDF-export-completion hook (an extra call site found while grepping, not called out in the original report, but it dispatched the old per-link signature too) - `apps/specs/admin.py`: dropped `confirmation_comment_id` from the readonly fields, registered a `ForgejoIssueCommentAdmin` following the same convention as `ForgejoRepoWebhookAdmin`. - Tests: updated every assertion on the old per-link signature/field across `apps/specs/test_issue_sync.py`, `apps/specs/test_issue_links.py`, and `apps/exports/tests.py`; added tests for (a) two links on the same issue grouping into one `create_comment` call containing both specs, (b) a no-op when the `(repo, issue)` pair has zero links, and (c) dedup at the webhook and poll call sites (two links detected/changed on the same issue dispatch exactly once). ## Test plan - `pytest apps/specs apps/exports` -- 175 passed locally. - `pytest apps` (full suite) -- 210 passed locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013EeueXTWCT4Y6EbeideZcm
feature: group the Forgejo issue-link confirmation comment per issue
Some checks failed
ci / test (pull_request) Failing after 3m32s
ci / e2e (pull_request) Has been skipped
ci / docker (pull_request) Has been skipped
ci / deploy (pull_request) Has been skipped
4edb6bcc13
sync_confirmation_comment used to post/edit one comment per
SpecVersionIssueLink (comment id tracked on the link itself), so an
issue linked to several specs got spammed with one "Spec liée" comment
per spec. Add ForgejoIssueComment, tracking a single comment id per
(repo_full_name, issue_number), and rewrite the task to gather every
link on that issue into one grouped "Specs liées" comment, edited in
place afterward.

Update the five dispatch call sites (SpecViewSet.create_issue,
SpecVersionIssueLinkViewSet.perform_create, ForgejoIssueWebhookView.post,
poll_stale_issue_links, and the PDF-export-completion hook in
apps.exports.tasks) to pass (repo_full_name, issue_number) instead of
a link pk, deduping to one dispatch per (repo, issue) pair at the two
sites where several changed/created links can share one pair in the
same sync -- dispatching per link there would race two task runs to
create the same ForgejoIssueComment row.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EeueXTWCT4Y6EbeideZcm
Gilles scheduled this pull request to auto merge when all checks succeed 2026-11-01 18:57:57 +00:00
Author
Owner
<!-- argus-link-bot:thierryade/backend --> 📊 [Rapports Argus pour cette PR](https://reports.stationmyr.net/thierryade/backend/pr/36)
chore: autopep8-wrap the generated migration's long BigAutoField line
All checks were successful
ci / test (pull_request) Successful in 3m38s
ci / e2e (pull_request) Has been skipped
ci / docker (pull_request) Has been skipped
ci / deploy (pull_request) Has been skipped
5b883fc3fd
makemigrations never runs its output through autopep8, so the
generated 0013 migration's CreateModel field line (the standard
BigAutoField pk Django emits verbatim for every model) was 10 chars
over the project's 99-char limit -- failing CI's format-check
(autopep8 --diff --exit-code), confirmed by rebuilding a clean venv
and running tox's four checks directly (lint/pytest+coverage/bandit
all passed; only format-check failed, on this exact line).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EeueXTWCT4Y6EbeideZcm
Gilles merged commit 18ebf0a101 into master 2026-11-01 19:26:03 +00:00
Gilles deleted branch feature/group-issue-link-comments 2026-11-01 19:26:03 +00:00
Sign in to join this conversation.
No description provided.