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

Order get reports by start time #289

Merged
merged 3 commits into from
Apr 13, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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