Skip to content

Commit

Permalink
Also show rejected packages in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 14, 2024
1 parent 9cb8ae2 commit 9a0638c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions assets/vue/CavilStatistics.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template>
<div class="row">
<div class="col-md-2">
<div class="stats">
<div class="stats-body">{{ activePackages }}</div>
<div class="stats-description">Active Packages</div>
</div>
</div>
<div class="col-md-2">
<div class="stats">
<div class="stats-body">{{ openReviews }}</div>
Expand All @@ -8,8 +14,8 @@
</div>
<div class="col-md-2">
<div class="stats">
<div class="stats-body">{{ activePackages }}</div>
<div class="stats-description">Active Packages</div>
<div class="stats-body">{{ rejectedPackages }}</div>
<div class="stats-description">Rejected Packages</div>
</div>
</div>
<div class="col-md-2">
Expand All @@ -33,14 +39,16 @@ export default {
embargoedPackages: 0,
openReviews: 0,
refreshDelay: 120000,
refreshUrl: '/stats/meta'
refreshUrl: '/stats/meta',
rejectedPackages: 0
};
},
methods: {
refreshData(data) {
this.activePackages = data.active_packages;
this.embargoedPackages = data.embargoed_packages;
this.openReviews = data.open_reviews;
this.rejectedPackages = data.rejected_packages;
}
}
};
Expand Down
1 change: 1 addition & 0 deletions lib/Cavil/Model/Packages.pm
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ sub stats {
"SELECT
(SELECT COUNT(*) FROM bot_packages WHERE obsolete = false) AS active_packages,
(SELECT COUNT(*) FROM bot_packages WHERE obsolete = false AND embargoed = true) AS embargoed_packages,
(SELECT COUNT(*) FROM bot_packages WHERE obsolete = false AND state = 'unacceptable') AS rejected_packages,
(SELECT COUNT(*) FROM bot_packages WHERE obsolete = false AND state = 'new') AS open_reviews"
)->hash;

Expand Down
2 changes: 1 addition & 1 deletion t/stats.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ subtest 'Statistics' => sub {

$t->get_ok('/stats')->status_is(200)->content_like(qr/id="statistics"/);
$t->get_ok('/stats/meta')->status_is(200)->json_is('/active_packages', 2)->json_is('/embargoed_packages', 0)
->json_is('/open_reviews' => 2);
->json_is('/open_reviews' => 2)->json_is('/rejected_packages' => 0);

$t->get_ok('/logout')->status_is(302)->header_is(Location => '/');
};
Expand Down

0 comments on commit 9a0638c

Please sign in to comment.