Skip to content

Commit

Permalink
Order get reports by start time (#289)
Browse files Browse the repository at this point in the history
* fix(reports): get reports by order of ended or started time

* fix(reports): get reports by order of ended or started time

* fix(reports): get reports by order of ended or started time
  • Loading branch information
enudler authored Apr 13, 2020
1 parent 1edf93f commit 2b9dc49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/reports/models/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async function handleAbort(report, job) {

async function handleBenchmarkWebhookTreshhold(aggregatedReport, score, benchmarkThreshold, benchmarkWebhook) {
if (score && benchmarkThreshold && score < benchmarkThreshold) {
const lastReports = await reportsManager.getReports(aggregatedReport.test_id, true);
const lastReports = await reportsManager.getReports(aggregatedReport.test_id);
const lastScores = lastReports.slice(0, 3).filter(report => report.score).map(report => report.score.toFixed(1));
let benchmarkWebhookMsg = `:sad_1: *Test ${aggregatedReport.test_name} got a score of ${score.toFixed(1)}` +
` this is below the threshold of ${benchmarkThreshold}. ${lastScores.length > 0 ? `last 3 scores are: ${lastScores.join()}` : 'no last score to show'}` +
Expand Down
6 changes: 2 additions & 4 deletions src/reports/models/reportsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ module.exports.getReport = async (testId, reportId) => {
return report;
};

module.exports.getReports = async (testId, sort = false) => {
module.exports.getReports = async (testId) => {
let reportSummaries = await databaseConnector.getReports(testId);
let config = await configHandler.getConfig();
let reports = reportSummaries.map((summaryRow) => {
return getReportResponse(summaryRow, config);
});
if (sort) {
reports.sort((a, b) => b.end_time - a.end_time);
}
reports.sort((a, b) => b.start_time - a.start_time);
return reports;
};

Expand Down

0 comments on commit 2b9dc49

Please sign in to comment.