Skip to content

Commit 9a2f92e

Browse files
committed
Make the number of builds per group on the front page configurable
The number of builds to show per job group on the front page of the web UI is hardcoded to 3. SUSE's openQA has a ton of job groups so only showing three per group makes sense, but not every instance has so many groups, and the front page can look unnecessarily empty. This allows the instance maintainer to set an appropriate value. The value can be overridden for a single query with the limit_builds query param, but that's unwieldy and doesn't solve things for casual views of the home page. Signed-off-by: Adam Williamson <[email protected]>
1 parent 3b29f9a commit 9a2f92e

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

etc/openqa/openqa.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125
## resilient in case of a high load on the web UI. Lower values reduce this risk but
126126
## can cause jobs to incomplete with "timestamp mismatch" error messages.
127127
#api_hmac_time_tolerance = 300
128+
## How many builds to show per job group on the web UI front page
129+
## Can be overridden with the limit_builds query param
130+
# frontpage_builds = 3
128131

129132
## Configuration related to actions openQA may perform on a git distri
130133
#[scm git]

lib/OpenQA/Setup.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ sub read_config ($app) {
9696
service_port_delta => $ENV{OPENQA_SERVICE_PORT_DELTA} // 2,
9797
access_control_allow_origin_header => undef,
9898
api_hmac_time_tolerance => 300,
99+
frontpage_builds => 3,
99100
},
100101
rate_limits => {
101102
search => 5,

lib/OpenQA/WebAPI/Controller/Main.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sub dashboard_build_results ($self) {
2323
$validation->optional('group');
2424
return $self->reply->validation_error({format => $self->accepts('html', 'json')}) if $validation->has_error;
2525

26-
my $limit_builds = $validation->param('limit_builds') // 3;
26+
my $limit_builds = $validation->param('limit_builds') // $self->app->config->{global}->{frontpage_builds};
2727
my $time_limit_days = $validation->param('time_limit_days') // 14;
2828
my $only_tagged = $validation->param('only_tagged') // 0;
2929
my $default_expanded = $validation->param('default_expanded') // 0;

t/22-dashboard.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,22 @@ is_deeply(\@h4, [qw(Build87.5011 Build0048@0815 Build0048)], 'builds on parent-l
147147
@h4 = $t->tx->res->dom->find('div.collapse .h4 a')->map('text')->each;
148148
is_deeply(\@h4, ['opensuse', 'opensuse', 'opensuse'], 'opensuse now shown as child group (for each build)');
149149

150-
# check build limit
150+
# check config file build limit
151+
my $ogfpb = $t->app->config->{global}->{frontpage_builds};
152+
$t->app->config->{global}->{frontpage_builds} = 1;
153+
$t->get_ok('/dashboard_build_results')->status_is(200);
154+
@h4 = $t->tx->res->dom->find('div.children-collapsed .h4 a')->map('text')->each;
155+
is_deeply(\@h4, [qw(Build87.5011)], 'single build on parent-level shown (limit builds via config)');
156+
157+
# check query param build limit works and overrides config file limit
151158
$t->get_ok('/dashboard_build_results?limit_builds=2')->status_is(200);
152159
@h4 = $t->tx->res->dom->find('div.children-collapsed .h4 a')->map('text')->each;
153160
is_deeply(\@h4, [qw(Build87.5011 Build0048@0815)], 'builds on parent-level shown (limit builds)');
154161
@h4 = $t->tx->res->dom->find('div.collapse .h4 a')->map('text')->each;
155162
is_deeply(\@h4, ['opensuse', 'opensuse'], 'opensuse now shown as child group (limit builds)');
156163

164+
$t->app->config->{global}->{frontpage_builds} = $ogfpb;
165+
157166
# also add opensuse test to parent to actually check the grouping
158167
my $opensuse_test_group = $job_groups->find({name => 'opensuse test'});
159168
$opensuse_test_group->update({parent_id => $test_parent->id});

t/config.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ subtest 'Test configuration default modes' => sub {
6666
parallel_children_collapsable_results_sel => ' .status:not(.result_passed):not(.result_softfailed)',
6767
auto_clone_limit => 20,
6868
api_hmac_time_tolerance => 300,
69+
frontpage_builds => 3,
6970
},
7071
rate_limits => {
7172
search => 5,

0 commit comments

Comments
 (0)