mirror of
https://github.com/block/buzz.git
synced 2026-11-16 06:11:34 +00:00
fix(db): seek directly between invite repair communities
Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz> Signed-off-by: Brad Seiler <seiler@squareup.com>
This commit is contained in:
@@ -189,8 +189,13 @@ async fn legacy_fixture() -> (PgPool, Vec<LegacyInviteCase>) {
|
||||
|
||||
let issuer = [1u8; 32];
|
||||
let mut cases = Vec::new();
|
||||
// Exercise cached successor lookups and the smallest valid UUID.
|
||||
for index in 0u8..12 {
|
||||
let community = Uuid::new_v4();
|
||||
let community = if index == 0 {
|
||||
Uuid::nil()
|
||||
} else {
|
||||
Uuid::new_v4()
|
||||
};
|
||||
sqlx::query("INSERT INTO communities (id, host) VALUES ($1, $2)")
|
||||
.bind(community)
|
||||
.bind(format!("upgrade-{index}-{community}.example"))
|
||||
|
||||
@@ -34,11 +34,18 @@ DECLARE
|
||||
affected BIGINT;
|
||||
BEGIN
|
||||
LOOP
|
||||
SELECT id INTO target_community
|
||||
FROM communities
|
||||
WHERE last_community IS NULL OR id > last_community
|
||||
ORDER BY id
|
||||
LIMIT 1;
|
||||
IF last_community IS NULL THEN
|
||||
SELECT id INTO target_community
|
||||
FROM communities
|
||||
ORDER BY id
|
||||
LIMIT 1;
|
||||
ELSE
|
||||
SELECT id INTO target_community
|
||||
FROM communities
|
||||
WHERE id > last_community
|
||||
ORDER BY id
|
||||
LIMIT 1;
|
||||
END IF;
|
||||
EXIT WHEN NOT FOUND;
|
||||
last_community := target_community;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user