Skip to content

Commit 17502ba

Browse files
committed
Allow filtering recent reviews by AI use
1 parent a371239 commit 17502ba

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

assets/vue/RecentReviews.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<label class="form-label">Reviews per Page</label>
1515
</div>
1616
</div>
17-
<div class="col">
17+
<div class="col-lg-2">
1818
<div class="form-check">
1919
<input
2020
v-model="params.byUser"
@@ -25,6 +25,18 @@
2525
/>
2626
<label class="form-check-label" for="cavil-pkg-by-user">Reviewed By User</label>
2727
</div>
28+
<div class="form-check">
29+
<input
30+
v-model="params.aiAssisted"
31+
@change="gotoPage(1)"
32+
type="checkbox"
33+
class="form-check-input"
34+
id="cavil-pkg-ai-assisted"
35+
/>
36+
<label class="form-check-label" for="cavil-pkg-ai-assisted">Reviewed With AI</label>
37+
</div>
38+
</div>
39+
<div class="col">
2840
<div class="form-check">
2941
<input
3042
v-model="params.unresolvedMatches"
@@ -161,14 +173,20 @@ export default {
161173
162174
const reviews = [];
163175
for (const review of data.page) {
176+
const login = [];
177+
if (review.login) {
178+
login.push(review.login);
179+
if (review.ai_assisted) login.push('<i class="fas fa-robot"></i>');
180+
}
181+
164182
reviews.push({
165183
link: externalLink(review),
166184
created: moment(review.created_epoch * 1000).fromNow(),
167185
reviewed: moment(review.reviewed_epoch * 1000).fromNow(),
168186
package: packageLink(review),
169187
priority: review.priority,
170188
report: reportLink(review),
171-
login: review.login,
189+
login: login.join(' '),
172190
result: review.result,
173191
state: review.state
174192
});
@@ -183,7 +201,7 @@ export default {
183201
}
184202
},
185203
watch: {
186-
...genParamWatchers('limit', 'offset', 'byUser', 'unresolvedMatches'),
204+
...genParamWatchers('limit', 'offset', 'byUser', 'aiAssisted', 'unresolvedMatches'),
187205
filter: function (val) {
188206
this.params.filter = val;
189207
this.params.offset = 0;

lib/Cavil/Controller/Pagination.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,14 @@ sub recent_reviews ($self) {
145145
$v->optional('limit')->num;
146146
$v->optional('offset')->num;
147147
$v->optional('byUser');
148+
$v->optional('aiAssisted');
148149
$v->optional('unresolvedMatches');
149150
$v->optional('filter');
150151
return $self->reply->json_validation_error if $v->has_error;
151152
my $limit = $v->param('limit') // 10;
152153
my $offset = $v->param('offset') // 0;
153154
my $by_user = $v->param('byUser') // 'false';
155+
my $ai_assisted = $v->param('aiAssisted') // 'false';
154156
my $unresolved_matches = $v->param('unresolvedMatches') // 'false';
155157
my $search = $v->param('filter') // '';
156158

@@ -159,6 +161,7 @@ sub recent_reviews ($self) {
159161
limit => $limit,
160162
offset => $offset,
161163
by_user => $by_user,
164+
ai_assisted => $ai_assisted,
162165
unresolved_matches => $unresolved_matches,
163166
search => $search
164167
}

lib/Cavil/Model/Packages.pm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ sub has_file_stats ($self, $id) {
148148
return defined($self->pg->db->select('bot_packages', 'unpacked_files', {id => $id})->hash->{unpacked_files});
149149
}
150150

151-
sub has_human_review ($self, $name) {
151+
sub has_manual_review ($self, $name) {
152152
return !!$self->pg->db->query('SELECT COUNT(*) FROM bot_packages WHERE name = ? AND reviewing_user IS NOT NULL',
153153
$name)->array->[0];
154154
}
@@ -330,20 +330,25 @@ sub paginate_recent_reviews ($self, $options) {
330330
$user = 'AND p.reviewing_user IS NOT NULL';
331331
}
332332

333+
my $ai_assisted = '';
334+
if ($options->{ai_assisted} eq 'true') {
335+
$ai_assisted = 'AND p.ai_assisted = true';
336+
}
337+
333338
my $unresolved = '';
334339
if ($options->{unresolved_matches} eq 'true') {
335340
$unresolved = "AND unresolved_matches > 0";
336341
}
337342

338343
my $results = $db->query(
339344
qq{
340-
SELECT p.id, p.name, u.login, p.result, EXTRACT(EPOCH FROM p.created) AS created_epoch,
345+
SELECT p.id, p.name, u.login, p.result, p.ai_assisted, EXTRACT(EPOCH FROM p.created) AS created_epoch,
341346
EXTRACT(EPOCH FROM p.reviewed) AS reviewed_epoch, EXTRACT(EPOCH FROM p.imported) as imported_epoch,
342347
EXTRACT(EPOCH FROM p.unpacked) as unpacked_epoch, EXTRACT(EPOCH FROM p.indexed) as indexed_epoch,
343348
external_link, priority, state, checksum, unresolved_matches, COUNT(*) OVER() AS total
344349
FROM bot_packages p
345350
LEFT JOIN bot_users u ON p.reviewing_user = u.id
346-
WHERE reviewed IS NOT NULL AND reviewed > NOW() - INTERVAL '90 DAYS' $search $user $unresolved
351+
WHERE reviewed IS NOT NULL AND reviewed > NOW() - INTERVAL '90 DAYS' $search $user $ai_assisted $unresolved
347352
ORDER BY reviewed DESC
348353
LIMIT ? OFFSET ?
349354
}, $options->{limit}, $options->{offset}

lib/Cavil/Task/Analyze.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ sub _analyzed ($job, $id) {
112112

113113
# Every package needs a human review before future versions can be auto-accepted, and checkouts need to be complete
114114
my $specfile = $reports->specfile_report($id);
115-
if (!$pkgs->has_human_review($pkg->{name}) || $specfile->{incomplete_checkout}) {
115+
if (!$pkgs->has_manual_review($pkg->{name}) || $specfile->{incomplete_checkout}) {
116116
_look_for_smallest_delta($app, $pkg, 0, 0, !!$specfile->{incomplete_checkout}) if $pkg->{state} eq 'new';
117117
return;
118118
}
@@ -149,6 +149,7 @@ sub _analyzed ($job, $id) {
149149
$pkg->{state} = 'acceptable_by_lawyer';
150150
$pkg->{review_timestamp} = 1;
151151
$pkg->{reviewing_user} = undef;
152+
$pkg->{ai_assisted} = 0;
152153
$pkg->{result} = "Accepted because reviewed by lawyer under the same license ($c_id)";
153154
$pkgs->update($pkg);
154155
}
@@ -186,7 +187,7 @@ sub _analyzed ($job, $id) {
186187
_look_for_smallest_delta($app, $pkg, 1, 1, 0) if $pkg->{state} eq 'new';
187188
}
188189

189-
sub _look_for_smallest_delta ($app, $pkg, $allow_accept, $has_human_review, $incomplete_checkout) {
190+
sub _look_for_smallest_delta ($app, $pkg, $allow_accept, $has_manual_review, $incomplete_checkout) {
190191
my $reports = $app->reports;
191192
my $pkgs = $app->packages;
192193

@@ -215,7 +216,7 @@ sub _look_for_smallest_delta ($app, $pkg, $allow_accept, $has_human_review, $inc
215216
if ($incomplete_checkout) {
216217
$pkg->{notice} .= ', manual review is required because the checkout might be incomplete';
217218
}
218-
elsif (!$has_human_review) {
219+
elsif (!$has_manual_review) {
219220
$pkg->{notice} .= ', manual review is required because previous reports are missing a reviewing user';
220221
}
221222

0 commit comments

Comments
 (0)