From 5d30e120b3a107b69354c93074ab759563786910 Mon Sep 17 00:00:00 2001 From: Antoine Ceol Date: Mon, 10 May 2021 16:00:15 +0200 Subject: [PATCH] fixup! Sort PR with in progress last --- common/services/github.js | 11 ++++++----- test/unit/build/services/github_test.js | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/common/services/github.js b/common/services/github.js index bd14a8c3..b5f2b645 100644 --- a/common/services/github.js +++ b/common/services/github.js @@ -79,15 +79,16 @@ function createResponseForSlack(data, label) { pretext: '', fields:[ {value: message, short: false},], }; - }); + }).sort((a, _) => { + // slack will display in the inverse order + const field = a.fields[0].value; + return field.indexOf(':construction:')?-1:1 + }) const response = { response_type: 'in_channel', text: 'PRs à review pour ' + label, - attachments: attachments.sort((a, b) => { - const field = a.fields[0].value; - return field.indexOf(':construction:')?-1:1 - }) + attachments }; return response; diff --git a/test/unit/build/services/github_test.js b/test/unit/build/services/github_test.js index ca57c2af..777e9c53 100644 --- a/test/unit/build/services/github_test.js +++ b/test/unit/build/services/github_test.js @@ -28,8 +28,8 @@ describe('#getPullRequests', function() { response_type: 'in_channel', text: 'PRs à review pour team-certif', attachments: [ - { color: '#B7CEF5', pretext: '', fields: [{ value: '[❌x1]:construction: :idea:', short: false }] }, - { color: '#B7CEF5', pretext: '', fields: [{ value: '[💬x1|✅x1]', short: false }] } + { color: '#B7CEF5', pretext: '', fields: [{ value: '❌x1 | :construction: :idea: | ', short: false }] }, + { color: '#B7CEF5', pretext: '', fields: [{ value: '💬x1 ✅x1 | ', short: false }] } ] };