Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort incidents on blocked page by priority in descending order #844

Merged
merged 5 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ Content-Type: application/json
"approved": false,
"emu": true,
"isActive": true,
"embargoed": false
"embargoed": false,
"priority": 500
},
...
]
Expand Down Expand Up @@ -129,7 +130,8 @@ Content-Type: application/json
"approved": false,
"emu": true,
"isActive": true,
"embargoed": false
"embargoed": false,
"priority": 500
}
```

Expand Down Expand Up @@ -158,7 +160,8 @@ None
"approved": false,
"emu": true,
"isActive": true,
"embargoed": false
"embargoed": false,
"priority": 500
},
...
]
Expand Down Expand Up @@ -197,7 +200,8 @@ None
"approved": false,
"emu": true,
"isActive": true,
"embargoed": false
"embargoed": false,
"priority": 500
}
```

Expand Down
4 changes: 2 additions & 2 deletions assets/vue/components/PageBlocked.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="col-auto my-1">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="checkbox" v-model="groupFlavors" />
<label class="form-check-label" for="checkbox"> Group Flavors </label>
<label class="form-check-label" for="checkbox"> Group Flavors</label>
</div>
</div>
</div>
Expand Down Expand Up @@ -99,7 +99,7 @@ export default {
searchParams.delete('group_names');
}
history.pushState({}, '', url);
return results;
return results.sort((a, b) => (b.incident.priority || 0) - (a.incident.priority || 0));
},
smelt() {
return this.appConfig.smeltUrl;
Expand Down
16 changes: 16 additions & 0 deletions assets/vue/components/PageIncident.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
<h4>Aggregate Runs Including This Incident</h4>
<IncidentBuildSummary v-for="build in sortedBuilds" :key="build" :build="build" :jobs="jobs[build]" />
</div>

<div class="details">
<h4>Further details</h4>
<table>
<tr v-for="field in ['Approved', 'Active', 'Embargoed', 'Priority', 'Project']" :key="field">
<th>{{ field }}</th>
<td>{{ renderFieldValue(incident, field) }}</td>
</tr>
</table>
</div>
</div>
<div v-else><i class="fas fa-sync fa-spin"></i> Loading incident...</div>
</template>
Expand Down Expand Up @@ -98,6 +108,12 @@ export default {
this.summary = details.incident_summary;
this.jobs = details.jobs;
}
},
renderFieldValue(incident, field) {
const fieldName = field.toLowerCase();
const displayTypes = {approved: 'yesno', active: 'yesno', embargoed: 'yesno'};
const value = incident[fieldName];
return displayTypes[fieldName] === 'yesno' ? (value ? 'yes' : 'no') : value ? value : 'none';
}
}
};
Expand Down
3 changes: 2 additions & 1 deletion lib/Dashboard/Controller/API/Incidents.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ my $INCIDENT_SPEC = {
approved => {type => 'boolean'},
emu => {type => 'boolean'},
isActive => {type => 'boolean'},
embargoed => {type => 'boolean'}
embargoed => {type => 'boolean'},
priority => {anyOf => [{type => 'integer'}, {type => 'null'}]},
}
};

Expand Down
8 changes: 4 additions & 4 deletions lib/Dashboard/Model/Incidents.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ sub build_nr ($self, $inc) {

sub find ($self, $options = {}) {
my $incidents = $self->pg->db->query(
'SELECT number, project, packages, rr_number, review, review_qam, approved, emu, embargoed, ARRAY_AGG(c.name) as channels
'SELECT number, project, packages, rr_number, review, review_qam, approved, emu, embargoed, priority, ARRAY_AGG(c.name) as channels
FROM incidents i INNER JOIN incident_channels ic ON ic.incident = i.id INNER JOIN channels c ON ic.channel = c.id
WHERE number = COALESCE(?, number) AND active = TRUE
GROUP BY number, project, packages, rr_number, review, review_qam, approved, emu, active, embargoed ORDER BY number',
GROUP BY number, project, packages, rr_number, review, review_qam, approved, emu, active, embargoed, priority ORDER BY number',
$options->{number}
)->hashes->to_array;
@{$_}{qw(isActive inReview inReviewQAM)} = (1, delete $_->{review}, delete $_->{review_qam}) for @$incidents;
Expand Down Expand Up @@ -256,9 +256,9 @@ sub _update ($self, $db, $incident) {

$db->query(
'UPDATE incidents SET packages = ?, rr_number = ?, review = ?, review_qam = ?, approved = ?, emu = ?, active = ?,
embargoed = ? WHERE id = ?', $incident->{packages}, $incident->{rr_number}, $incident->{inReview},
embargoed = ?, priority = ? WHERE id = ?', $incident->{packages}, $incident->{rr_number}, $incident->{inReview},
$incident->{inReviewQAM}, $incident->{approved}, $incident->{emu}, $incident->{isActive}, $incident->{embargoed},
$id
$incident->{priority}, $id
Martchus marked this conversation as resolved.
Show resolved Hide resolved
);

# Remove old jobs after release request number changed (because incidents might be reused)
Expand Down
3 changes: 3 additions & 0 deletions migrations/dashboard.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ ALTER TABLE openqa_jobs ADD COLUMN obsolete BOOLEAN DEFAULT FALSE;

--6 up
ALTER TABLE incidents ADD COLUMN embargoed BOOLEAN DEFAULT FALSE;

--7 up
ALTER TABLE incidents ADD COLUMN priority INTEGER;
67 changes: 44 additions & 23 deletions t/api.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ $dashboard_test->no_fixtures($t->app);
my $auth_headers = {Authorization => 'Token test_token', Accept => 'application/json'};

subtest 'Migrations' => sub {
is $t->app->pg->migrations->latest, 6, 'latest version';
is $t->app->pg->migrations->active, 6, 'active version';
is $t->app->pg->migrations->latest, 7, 'latest version';
is $t->app->pg->migrations->active, 7, 'active version';
};

subtest 'Unknown endpoint' => sub {
Expand Down Expand Up @@ -68,7 +68,8 @@ subtest 'JSON schema validation failed' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => true
embargoed => true,
priority => undef,
}
]
)->status_is(400);
Expand All @@ -86,7 +87,8 @@ subtest 'JSON schema validation failed' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
)->status_is(400);
like $t->tx->res->json('/error'), qr/Incident does not match the JSON schema:.+/, 'right error';
Expand All @@ -105,7 +107,8 @@ subtest 'JSON schema validation failed' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
]
)->status_is(400);
Expand All @@ -123,7 +126,8 @@ subtest 'JSON schema validation failed' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
)->status_is(400);
like $t->tx->res->json('/error'), qr/Expected boolean - got array/, 'right error';
Expand All @@ -144,7 +148,8 @@ subtest 'Add incident' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => false
embargoed => false,
priority => 123,
}
]
)->status_is(200)->json_is({message => 'Ok'});
Expand All @@ -163,7 +168,8 @@ subtest 'Add incident' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => false
embargoed => false,
priority => 123,
}
]
);
Expand All @@ -181,7 +187,8 @@ subtest 'Add incident' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => false
embargoed => false,
priority => 123,
}
);
$t->get_ok('/api/incidents/1' => $auth_headers)->status_is(404)->json_is({error => 'Incident not found'});
Expand All @@ -201,7 +208,8 @@ subtest 'Update incident' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => true
embargoed => true,
priority => 456,
}
]
)->status_is(200)->json_is({message => 'Ok'});
Expand All @@ -219,7 +227,8 @@ subtest 'Update incident' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => true
embargoed => true,
priority => 456,
}
]
);
Expand All @@ -236,7 +245,8 @@ subtest 'Update incident' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => true
embargoed => true,
priority => 456,
}
);
$t->get_ok('/api/incidents/1' => $auth_headers)->status_is(404)->json_is({error => 'Incident not found'});
Expand Down Expand Up @@ -274,7 +284,8 @@ subtest 'Obsolete incident' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
]
);
Expand All @@ -291,7 +302,8 @@ subtest 'Obsolete incident' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
);
$t->get_ok('/api/incidents/16860' => $auth_headers)->status_is(404)->json_is({error => 'Incident not found'});
Expand All @@ -310,7 +322,8 @@ subtest 'Update individual incidents' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
)->status_is(200)->json_is({message => 'Ok'});

Expand All @@ -326,7 +339,8 @@ subtest 'Update individual incidents' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
);
$t->get_ok('/api/incidents/16862' => $auth_headers)->status_is(200)->json_is(
Expand All @@ -341,7 +355,8 @@ subtest 'Update individual incidents' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
);

Expand All @@ -357,7 +372,8 @@ subtest 'Update individual incidents' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => true
embargoed => true,
priority => undef,
}
)->status_is(200)->json_is({message => 'Ok'});

Expand All @@ -374,7 +390,8 @@ subtest 'Update individual incidents' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
},
{
number => 16862,
Expand All @@ -387,7 +404,8 @@ subtest 'Update individual incidents' => sub {
approved => false,
emu => false,
isActive => true,
embargoed => true
embargoed => true,
priority => undef,
}
]
);
Expand All @@ -404,7 +422,8 @@ subtest 'Update individual incidents' => sub {
approved => false,
emu => false,
isActive => false,
embargoed => false
embargoed => false,
priority => undef,
}
)->status_is(200)->json_is({message => 'Ok'});
$t->get_ok('/api/incidents/16862' => $auth_headers)->status_is(404)->json_is({error => 'Incident not found'});
Expand Down Expand Up @@ -764,7 +783,8 @@ subtest 'Authentication' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => true
embargoed => true,
priority => undef,
}
]
)->status_is(403)->json_is({error => 'Permission denied'});
Expand All @@ -782,7 +802,8 @@ subtest 'Authentication' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
]
)->status_is(200)->json_is({message => 'Ok'});
Expand Down
6 changes: 4 additions & 2 deletions t/api_cleanup.t
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ subtest 'Clean up jobs after rr_number change (during sync)' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => true
embargoed => true,
priority => undef,
}
]
)->status_is(200)->json_is({message => 'Ok'});
Expand Down Expand Up @@ -131,7 +132,8 @@ subtest 'Clean up jobs after rr_number change (during sync)' => sub {
approved => false,
emu => true,
isActive => true,
embargoed => false
embargoed => false,
priority => undef,
}
]
)->status_is(200)->json_is({message => 'Ok'});
Expand Down