Skip to content

fix gap for primary key in issues table#16

Merged
olajideolamide merged 2 commits into
mainfrom
bugfix/fix-issue-with-gaps-in-primary-keys-for-issues
May 24, 2026
Merged

fix gap for primary key in issues table#16
olajideolamide merged 2 commits into
mainfrom
bugfix/fix-issue-with-gaps-in-primary-keys-for-issues

Conversation

@olajideolamide
Copy link
Copy Markdown
Owner

fixed the gaps in issue primary keys

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

Review Change Stack

Warning

Review limit reached

@olajideolamide, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 23 minutes and 38 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b57386f6-a12f-4d69-9227-b0d614ec4dd8

📥 Commits

Reviewing files that changed from the base of the PR and between 7b08a9a and 9faf6ec.

📒 Files selected for processing (1)
  • src/Repositories/IssueRepository.php

Walkthrough

The MySQL atomic upsert path in IssueRepository was refactored to replace a single INSERT ... ON DUPLICATE KEY UPDATE statement with an insert-then-update-and-select approach. upsertIssueAtomic() now attempts insertion and falls back to updateExistingIssueAtomic() on exception or failure; the helper handles race conditions by updating existing rows and re-selecting the id with defensive validation.

Changes

Atomic Upsert Implementation

Layer / File(s) Summary
Main upsert entry point refactoring
src/Repositories/IssueRepository.php
upsertIssueAtomic() computes timestamps, attempts an insert for the fingerprint, and on exception or false result falls back to updateExistingIssueAtomic() helper to handle race conditions and return the existing issue id.
Existing row update helper
src/Repositories/IssueRepository.php
updateExistingIssueAtomic() performs a parameterized UPDATE that increments times_seen, applies last_seen, coalesces nullable fields, and remaps status from resolved to regression; validates affected rows and performs a follow-up SELECT id by fingerprint with error handling and result validation.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A fuzzy refactor hops through the data,
Where INSERT meets UPDATE in atomic grandiosity,
Racing conditions are caught in their tracks,
Two steps instead of one, yet none fall through the cracks! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and incomplete; it lacks the required template sections including Summary, Changes, How to test, and Checklist. Fill out the PR description template with detailed Summary, Changes list, testing steps, and verify all checklist items are addressed before merging.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing gaps in the primary key for the issues table, which aligns with the refactored upsert logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/fix-issue-with-gaps-in-primary-keys-for-issues

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Repositories/IssueRepository.php`:
- Line 160: The SQL currently forces level = ? which defaults to 'error' and can
overwrite existing higher severity; in upsertIssueLegacy change the assignment
to use COALESCE (e.g. "level = COALESCE(level, ?)") and update the bound value
for the level parameter to pass $issue['level'] or NULL (not the literal
'error') so the existing $existing['level'] is preserved when no new level is
provided; apply the same COALESCE change to the other occurrences referenced
(lines around the second assignment for level).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6d9d50a5-f877-43b0-8046-6da356eeef34

📥 Commits

Reviewing files that changed from the base of the PR and between 33c47f0 and 7b08a9a.

📒 Files selected for processing (1)
  • src/Repositories/IssueRepository.php

Comment thread src/Repositories/IssueRepository.php Outdated
@olajideolamide
Copy link
Copy Markdown
Owner Author

@coderabbitai resolve

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

✅ Actions performed

Comments resolved and changes approved.

@olajideolamide olajideolamide merged commit 791ee62 into main May 24, 2026
25 checks passed
@olajideolamide olajideolamide deleted the bugfix/fix-issue-with-gaps-in-primary-keys-for-issues branch May 24, 2026 19:04
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