• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openSUSE / qem-dashboard / 21755585779

06 Feb 2026 03:16PM UTC coverage: 94.25% (-1.7%) from 95.985%
21755585779

Pull #3059

github

web-flow
Merge cef2e8674 into 81685eda9
Pull Request #3059: PART 10: fix: display of "active" status - After #3058

248 of 282 new or added lines in 12 files covered. (87.94%)

8 existing lines in 3 files now uncovered.

1131 of 1200 relevant lines covered (94.25%)

9.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.87
/lib/Dashboard/Controller/API/Settings.pm
1
# Copyright SUSE LLC
2
# SPDX-License-Identifier: GPL-2.0-or-later
3

4
package Dashboard::Controller::API::Settings;
5
use Mojo::Base 'Mojolicious::Controller', -signatures;
12✔
6

7
use Mojo::JSON qw(true false);
12✔
8

9
sub add_incident_settings ($self) {
6✔
10
  if ($self->stash('openapi.path')) {
6✔
11
    return unless $self->openapi->valid_input;
6✔
12
  }
13
  else {
NEW
14
    return $self->render(json => {error => 'Settings in JSON format required'}, status => 400)
×
15
      unless my $settings = $self->req->json;
16

NEW
17
    my $jv     = $self->schema('incident_settings');
×
NEW
18
    my @errors = $jv->validate($settings);
×
NEW
19
    return $self->render(json => {error => "Settings do not match the JSON schema: @errors"}, status => 400) if @errors;
×
20
  }
21

22
  my $settings = $self->req->json;
6✔
23
  return $self->render(json => {error => 'Incident not found'}, status => 400)
24
    unless my $incident_id = $self->incidents->id_for_number($settings->{incident});
6✔
25

26
  my $id = $self->settings->add_incident_settings($incident_id, $settings);
4✔
27
  $self->render(json => {message => 'Ok', id => $id});
4✔
28
}
29

30
sub add_update_settings ($self) {
4✔
31
  if ($self->stash('openapi.path')) {
4✔
32
    return unless $self->openapi->valid_input;
4✔
33
  }
34
  else {
NEW
35
    return $self->render(json => {error => 'Settings in JSON format required'}, status => 400)
×
36
      unless my $settings = $self->req->json;
37

NEW
38
    my $jv     = $self->schema('update_settings');
×
NEW
39
    my @errors = $jv->validate($settings);
×
NEW
40
    return $self->render(json => {error => "Settings do not match the JSON schema: @errors"}, status => 400) if @errors;
×
41
  }
42

43
  my $settings = $self->req->json;
4✔
44
  my @incident_ids;
4✔
45
  my $incidents = $self->incidents;
4✔
46
  for my $incident (@{$settings->{incidents}}) {
4✔
47
    return $self->render(json => {error => 'Incident not found'}, status => 400)
6✔
48
      unless my $incident_id = $incidents->id_for_number($incident);
49
    push @incident_ids, $incident_id;
4✔
50
  }
51

52
  my $id = $self->settings->add_update_settings(\@incident_ids, $settings);
2✔
53
  $self->render(json => {message => 'Ok', id => $id});
2✔
54
}
55

56
sub get_incident_settings ($self) {
4✔
57
  return unless !$self->stash('openapi.path') || $self->openapi->valid_input;
4✔
58
  return $self->render(json => {error => 'Incident not found'}, status => 400)
4✔
59
    unless my $incident_id = $self->incidents->id_for_number($self->param('incident'));
60
  $self->render(json => _fix_booleans($self->settings->get_incident_settings($incident_id)));
2✔
61
}
62

63
sub get_update_settings ($self) {
×
NEW
64
  return unless !$self->stash('openapi.path') || $self->openapi->valid_input;
×
UNCOV
65
  return $self->render(json => {error => 'Incident not found'}, status => 400)
×
66
    unless my $incident_id = $self->incidents->id_for_number($self->param('incident'));
67
  $self->render(json => $self->settings->get_update_settings($incident_id));
×
68
}
69

70
sub search_update_settings ($self) {
×
NEW
71
  return unless !$self->stash('openapi.path') || $self->openapi->valid_input;
×
72

NEW
73
  my $product = $self->param('product');
×
NEW
74
  my $arch    = $self->param('arch');
×
NEW
75
  my $limit   = $self->param('limit');
×
76

77
  $self->render(json => $self->settings->find_update_settings({product => $product, arch => $arch, limit => $limit}));
×
78
}
79

80
sub _fix_booleans ($settings) {
2✔
81
  for my $setting (@$settings) {
2✔
82
    $setting->{withAggregate} = $setting->{withAggregate} ? true : false;
4✔
83
  }
84
  return $settings;
2✔
85
}
86

87
1;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc