-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<template> | ||
<div class="row"> | ||
<div class="col-md-2"> | ||
<div class="stats"> | ||
<div class="stats-body">{{ openReviews }}</div> | ||
<div class="stats-description">Open Reviews</div> | ||
</div> | ||
</div> | ||
<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">{{ embargoedPackages }}</div> | ||
<div class="stats-description">Embargoed Packages</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Refresh from './mixins/refresh.js'; | ||
export default { | ||
name: 'CavilStatistics', | ||
mixins: [Refresh], | ||
data() { | ||
return { | ||
activePackages: 0, | ||
embargoedPackages: 0, | ||
openReviews: 0, | ||
refreshDelay: 120000, | ||
refreshUrl: '/stats/meta' | ||
}; | ||
}, | ||
methods: { | ||
refreshData(data) { | ||
this.activePackages = data.active_packages; | ||
this.embargoedPackages = data.embargoed_packages; | ||
this.openReviews = data.open_reviews; | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style> | ||
div.stats { | ||
border: solid 1px #777; | ||
border-radius: 4px; | ||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); | ||
color: #777; | ||
margin-bottom: 20px; | ||
} | ||
div.stats .stats-description { | ||
font-size: 0.8em; | ||
padding: 0 15px 15px; | ||
text-align: center; | ||
} | ||
div.stats .stats-body { | ||
font-size: 26px; | ||
padding: 15px 15px 0; | ||
text-align: center; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (C) 2024 SUSE Linux GmbH | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, see <http://www.gnu.org/licenses/>. | ||
|
||
package Cavil::Controller::Stats; | ||
use Mojo::Base 'Mojolicious::Controller', -signatures; | ||
|
||
sub index ($self) { | ||
$self->render; | ||
} | ||
|
||
sub meta ($self) { | ||
my $stats = $self->packages->stats; | ||
$self->render(json => $stats); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (C) 2024 SUSE LLC | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, see <http://www.gnu.org/licenses/>. | ||
|
||
use Mojo::Base -strict; | ||
|
||
use FindBin; | ||
use lib "$FindBin::Bin/lib"; | ||
|
||
use Test::More; | ||
use Test::Mojo; | ||
use Cavil::Test; | ||
|
||
plan skip_all => 'set TEST_ONLINE to enable this test' unless $ENV{TEST_ONLINE}; | ||
|
||
my $cavil_test = Cavil::Test->new(online => $ENV{TEST_ONLINE}, schema => 'stats_test'); | ||
my $t = Test::Mojo->new(Cavil => $cavil_test->default_config); | ||
$cavil_test->mojo_fixtures($t->app); | ||
|
||
subtest 'Statistics' => sub { | ||
$t->get_ok('/login')->status_is(302)->header_is(Location => '/'); | ||
|
||
$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); | ||
|
||
$t->get_ok('/logout')->status_is(302)->header_is(Location => '/'); | ||
}; | ||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
% layout 'default'; | ||
% title 'Statistics'; | ||
|
||
<div id="statistics"></div> | ||
|
||
% content_for 'ready_function' => begin | ||
cavil.setupStatistics(); | ||
% end | ||
|