Skip to content

fix: deduplicate access logs before batch insert#1963

Merged
moshloop merged 1 commit intomainfrom
pr/fix-duplicate-logs
Mar 9, 2026
Merged

fix: deduplicate access logs before batch insert#1963
moshloop merged 1 commit intomainfrom
pr/fix-duplicate-logs

Conversation

@moshloop
Copy link
Member

@moshloop moshloop commented Mar 9, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Resolved duplicate log entries by deduplicating access logs before saving to the database, ensuring data integrity and preventing conflicts during database operations.

Prevents "ON CONFLICT DO UPDATE cannot affect row a second time" errors
when the same user appears in multiple access log entries for the same
config (e.g. user triggered a deployment AND approved it).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Adds deduplication logic for ConfigAccessLog entries in the database update process. Before saving logs, entries are merged based on a composite key (ConfigID, ExternalUserID, ScraperID), retaining only the entry with the most recent CreatedAt timestamp per key.

Changes

Cohort / File(s) Summary
ConfigAccessLog Deduplication
db/update.go
Introduces deduplication logic that consolidates duplicate ConfigAccessLog entries using a composite key before persistence, keeping the most recently created entry for each key combination.

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: deduplicate access logs before batch insert' directly and clearly describes the main change: deduplication of ConfigAccessLog entries before database insertion.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pr/fix-duplicate-logs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@moshloop moshloop enabled auto-merge (rebase) March 9, 2026 11:13
@moshloop moshloop merged commit f2ddd06 into main Mar 9, 2026
12 of 15 checks passed
@moshloop moshloop deleted the pr/fix-duplicate-logs branch March 9, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant