Skip to content

Commit 42eafb7

Browse files
authored
feat: /review code review requests with claim workflow (#49) (#114)
* feat: /review code review requests with claim workflow (#49) * fix(review): atomic claim, stale config, URL validation, error messages
1 parent 90b3c55 commit 42eafb7

9 files changed

Lines changed: 1589 additions & 1 deletion

File tree

config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
"rank": "everyone",
152152
"leaderboard": "everyone",
153153
"profile": "everyone",
154+
"review": "everyone",
154155
"showcase": "everyone"
155156
}
156157
},
@@ -204,5 +205,11 @@
204205
"announceChannelId": null,
205206
"levelThresholds": [100, 300, 600, 1000, 1500, 2500, 4000, 6000, 8500, 12000],
206207
"roleRewards": {}
208+
},
209+
"review": {
210+
"enabled": false,
211+
"channelId": null,
212+
"staleAfterDays": 7,
213+
"xpReward": 50
207214
}
208215
}

migrations/010_reviews.cjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Migration 010 — Code Review Requests
3+
* Creates the reviews table for the /review command.
4+
*
5+
* @see https://github.com/VolvoxLLC/volvox-bot/issues/49
6+
*/
7+
8+
'use strict';
9+
10+
/**
11+
* @param {import('pg').Pool} pool
12+
*/
13+
async function up(pool) {
14+
await pool.query(`
15+
CREATE TABLE IF NOT EXISTS reviews (
16+
id SERIAL PRIMARY KEY,
17+
guild_id TEXT NOT NULL,
18+
requester_id TEXT NOT NULL,
19+
reviewer_id TEXT,
20+
url TEXT NOT NULL,
21+
description TEXT NOT NULL,
22+
language TEXT,
23+
status TEXT DEFAULT 'open' CHECK (status IN ('open', 'claimed', 'completed', 'stale')),
24+
message_id TEXT,
25+
channel_id TEXT,
26+
thread_id TEXT,
27+
feedback TEXT,
28+
created_at TIMESTAMPTZ DEFAULT NOW(),
29+
claimed_at TIMESTAMPTZ,
30+
completed_at TIMESTAMPTZ
31+
);
32+
33+
CREATE INDEX IF NOT EXISTS idx_reviews_guild ON reviews(guild_id);
34+
CREATE INDEX IF NOT EXISTS idx_reviews_status ON reviews(guild_id, status);
35+
`);
36+
}
37+
38+
/**
39+
* @param {import('pg').Pool} pool
40+
*/
41+
async function down(pool) {
42+
await pool.query(`
43+
DROP INDEX IF EXISTS idx_reviews_status;
44+
DROP INDEX IF EXISTS idx_reviews_guild;
45+
DROP TABLE IF EXISTS reviews;
46+
`);
47+
}
48+
49+
module.exports = { up, down };

src/api/utils/configAllowlist.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const SAFE_CONFIG_KEYS = new Set([
2323
'reputation',
2424
'engagement',
2525
'github',
26+
'review',
2627
]);
2728

2829
export const READABLE_CONFIG_KEYS = [...SAFE_CONFIG_KEYS, 'logging'];

0 commit comments

Comments
 (0)