Skip to content

refactor(database): a one-table purge is written as its table and condition - #583

Merged
PiquelChips merged 2 commits into
mainfrom
refactor/544-database-purge-batches
Nov 21, 2026
Merged

PiquelChips merged 2 commits into
mainfrom
refactor/544-database-purge-batches

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Part of #544.

MaintenanceRepository::purge_expired_auth_state runs 24 delete statements. Fifteen of them delete a batch of one table's rows matching a condition, and each wrote out the same nine-line statement:

DELETE FROM t WHERE ctid IN (SELECT ctid FROM t WHERE … LIMIT $1 FOR UPDATE SKIP LOCKED)

purge!("table" where "condition") now writes that statement. The nine statements that join or alias keep their full SQL. The function adds up what each statement removed into purged, so each statement is its own purge! call and the comments stay next to the statement they explain.

Behavior. The statements are the same as before and run in the same order, and the first error still returns early.

Proof. 15 rewritten queries. In just db scratch, all 15 pair by identical generic plan and SQLx describe.

Tests. No test was merged or removed, and no file outside crates/database changed.

Checks: just fmt; cargo clippy -p sourceorigin-repository --all-targets with and without --all-features (-D warnings); cargo doc (-D warnings); doc tests; just rust unused; just db prepare. just db test: 497 of 497 pass, and its cache check passes.

Note

Written by Claude Opus 5.5 in Claude Code and reviewed by Claude Opus 5.5 (via T3 Code)

Fifteen of cleanup's 24 statements delete a batch of one table's rows
that match a condition, each spelling out the same nine-line statement.
`purge!("table" where "condition")` writes it, and the joined
statements stay as they were.
@PiquelChips PiquelChips added the refactor No behviour changes label Nov 20, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8fb52623-a7b4-4e03-bc01-55ca57372fb5
Commits

Reviewing files that changed from the base of the PR and between 467e813 and 563ac68.

Files selected for processing: 31

  • crates/database/.sqlx/query-0015a7a31c40e78d17b400b11f19a352d7d614002255b956f7277ed23855d1d3.json
  • crates/database/.sqlx/query-0b1e6403255951193fd80ef1c4fbfaf8c1f34161aca0b286c7e543f21f00e65b.json
  • crates/database/.sqlx/query-0d786a6ed79f853b1d9c9adbde54d68ab5fda8b03bf1fcdc57ee6d7792401978.json
  • crates/database/.sqlx/query-13e7a32572117990a0eb67e49daae24346c47d3eca4a0a73b0542c94ccc8029e.json
  • crates/database/.sqlx/query-1677e180168b55d131bb166f469cf718fb022b4a80a80fc1933aa47d1c8881ac.json
  • crates/database/.sqlx/query-17694894d73ef83c3208368da6e4386b0a7bb8445079e1a9bad2ab7dbfd7a829.json
  • crates/database/.sqlx/query-1b753be9686ca0f9370e1fcdafa235128994ad3bf8069c5bc86cf5e6d969c0c2.json
  • crates/database/.sqlx/query-1d4a9a1f67bcf68592dc09d37a700c7a523d8175c6022af0075c1ca36e9c191a.json
  • crates/database/.sqlx/query-3f68a50372f386a30304be409ba577447bf1483d582fd25c2f63468568954816.json
  • crates/database/.sqlx/query-458f34f5477f8874fab6c21f56db9686ac6fe6b9473cfb9923b3efd5d249c540.json
  • crates/database/.sqlx/query-467b762803df1cda514948abe73ff992d7a41598c70dccf99d3a22e128d23fc7.json
  • crates/database/.sqlx/query-7476979003c65646ab74ca2cd9e1e7f77f19b99d521a33372c63b87c153ed519.json
  • crates/database/.sqlx/query-7666eb01b7ccef00b5b1dea80a7a8043f25d0c615f8a51ed98293332233f6b95.json
  • crates/database/.sqlx/query-839eb35bacf2588e48f01b9d0a363d4547527f2868b48a9d4840552d75b47193.json
  • crates/database/.sqlx/query-85d9468b047ff386f202a5e3227dc492c0c86eeb42903168dfd54d2b7a4645e9.json
  • crates/database/.sqlx/query-87e29879d0a7d0923d65b8ca193e77a19e5223003dd0b5b4339a5e01b1bc050e.json
  • crates/database/.sqlx/query-886e43137c08600a7fdd6821818e3b1394718b273926df9323d4662fa486d6ad.json
  • crates/database/.sqlx/query-8b20d21d0913ee69fd46ada6e63af79e529c10ce0e0144a896e52bb2fc2f6118.json
  • crates/database/.sqlx/query-8f529870012b54461c249efdfeed0a5843ec6b9c5a97e76336cbea8409a7cd56.json
  • crates/database/.sqlx/query-94405ea4ea79665d1306c3d7c6cab9f0b52b1fb44d9097169324681ff3e600a3.json
  • crates/database/.sqlx/query-a25d691356e678ef3ef65aefb62eaec18df6ce522121fd55fb6fbc48a15f7f73.json
  • crates/database/.sqlx/query-be832e00fd156f8eb6a099f62c6b3c469bafbf26e4adb86c414c01d3788f5c1a.json
  • crates/database/.sqlx/query-c320da751bb997b2a754370f42ef2cc1dd5a571b2a30b9dbd402dd771ef8361e.json
  • crates/database/.sqlx/query-d75d045352aaa9aeb2746fa4298283d3bd9c080d34a3124cecd1f4452b145c79.json
  • crates/database/.sqlx/query-da1ea4df7b04ce065148aaa24982ebd1ab61dd30551624b92b580287dd5d8679.json
  • crates/database/.sqlx/query-e1b82dcff5286c2e267048a3261b8d584390fc374340cc1b78f71d79f8be4748.json
  • crates/database/.sqlx/query-e26adc5e8dd9dfd42dfcb63617179a968f577302301c589ff3504fb8dfade97c.json
  • crates/database/.sqlx/query-eb6bb66024947f552c3fa7e1e8b56725209b50a104c12f5027cc569852403506.json
  • crates/database/.sqlx/query-ecf64133f9a1f146f7244e6cb05e2d0aa5e25ef03fc3cdc684f94ee6ac89c359.json
  • crates/database/.sqlx/query-fb8ad58c1be4603e48f6e397d5ca91f9a7eae83fea6929d6aeaa573590a7a14f.json
  • crates/database/src/repositories/maintenance/mod.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@PiquelChips
PiquelChips marked this pull request as ready for review November 20, 2026 09:18
@PiquelChips
PiquelChips marked this pull request as draft November 21, 2026 14:00
@PiquelChips
PiquelChips marked this pull request as ready for review November 21, 2026 14:15
@PiquelChips
PiquelChips added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 42ed609 Nov 21, 2026
14 checks passed
@PiquelChips
PiquelChips deleted the refactor/544-database-purge-batches branch November 21, 2026 16:32
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in sourceorigin.dev Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor No behviour changes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant