From 1c7e6c5639338fc77f1483fb66d075dffc19d060 Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 10:07:48 -0500 Subject: [PATCH 01/12] DOP-4356 reverse slack modal sort --- .github/workflows/deploy-stg-ecs.yml | 1 + src/services/slack.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-stg-ecs.yml b/.github/workflows/deploy-stg-ecs.yml index 2967c5812..d25a9ea27 100644 --- a/.github/workflows/deploy-stg-ecs.yml +++ b/.github/workflows/deploy-stg-ecs.yml @@ -3,6 +3,7 @@ on: branches: - "main" - "integration" + - "DOP-4356" concurrency: group: environment-stg-${{ github.ref }} cancel-in-progress: true diff --git a/src/services/slack.ts b/src/services/slack.ts index 4cc0d39f2..e8012c2d9 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -197,7 +197,7 @@ export class SlackConnector implements ISlackConnector { if (reposToShow.length > 100) { reposToShow = reposToShow.splice(0, 100); } - reposToShow.sort(); + reposToShow.sort().reverse(); return this._getDropDownView(triggerId, reposToShow); } } From 32f60db2c125a4dc908a57c6bfe4ed164e3ed119 Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 10:29:03 -0500 Subject: [PATCH 02/12] DOP-4356 sort versions accurately --- src/services/slack.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index e8012c2d9..846d70d0f 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -197,7 +197,14 @@ export class SlackConnector implements ISlackConnector { if (reposToShow.length > 100) { reposToShow = reposToShow.splice(0, 100); } - reposToShow.sort().reverse(); + reposToShow + .sort((a, b) => + a + .toString() + .replace(/\d+/g, (n) => +n + 1000) + .localeCompare(b.text.toString().replace(/\d+/g, (n) => +n + 1000)) + ) + .reverse(); return this._getDropDownView(triggerId, reposToShow); } } From 1ae2db9f2404482c8bb2cc3bdc7ad151655f9af6 Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 10:52:04 -0500 Subject: [PATCH 03/12] DOP-4356 sort versions accurately --- src/services/slack.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index 846d70d0f..21d166903 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -197,14 +197,9 @@ export class SlackConnector implements ISlackConnector { if (reposToShow.length > 100) { reposToShow = reposToShow.splice(0, 100); } - reposToShow - .sort((a, b) => - a - .toString() - .replace(/\d+/g, (n) => +n + 1000) - .localeCompare(b.text.toString().replace(/\d+/g, (n) => +n + 1000)) - ) - .reverse(); + reposToShow.sort((a, b) => + a.text.replace(/\d+/g, (n) => +n + 1000).localeCompare(b.text.toString().replace(/\d+/g, (n) => +n + 1000)) + ); return this._getDropDownView(triggerId, reposToShow); } } From 6c8b44b1b8676103041a00f4bbced767ffa2d259 Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 11:11:15 -0500 Subject: [PATCH 04/12] DOP-4356 sort versions accurately --- src/services/slack.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index 21d166903..bd5ec4f3d 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -198,7 +198,10 @@ export class SlackConnector implements ISlackConnector { reposToShow = reposToShow.splice(0, 100); } reposToShow.sort((a, b) => - a.text.replace(/\d+/g, (n) => +n + 1000).localeCompare(b.text.toString().replace(/\d+/g, (n) => +n + 1000)) + a.text + .toString() + .replace(/\d+/g, (n) => +n + 1000) + .localeCompare(b.text.toString().replace(/\d+/g, (n) => +n + 1000)) ); return this._getDropDownView(triggerId, reposToShow); } From 66d78d6c33192f812feaa6dd7bee3e5539b7f3e6 Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 11:41:23 -0500 Subject: [PATCH 05/12] DOP-4356 checking sorting again --- src/services/slack.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index bd5ec4f3d..60cccaf84 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -198,10 +198,10 @@ export class SlackConnector implements ISlackConnector { reposToShow = reposToShow.splice(0, 100); } reposToShow.sort((a, b) => - a.text + b.text .toString() .replace(/\d+/g, (n) => +n + 1000) - .localeCompare(b.text.toString().replace(/\d+/g, (n) => +n + 1000)) + .localeCompare(a.text.toString().replace(/\d+/g, (n) => +n + 1000)) ); return this._getDropDownView(triggerId, reposToShow); } From 4c02be79d659aa3a5d4f9b58b4fef0bc7144113e Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 11:48:05 -0500 Subject: [PATCH 06/12] DOP-4356 sort before splice --- src/services/slack.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index 60cccaf84..b59a44347 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -194,15 +194,16 @@ export class SlackConnector implements ISlackConnector { // THis is the limitation enforced by slack as no more 100 items are allowd in the dropdown //'[ERROR] no more than 100 items allowed [json-pointer:/view/blocks/0/element/options]' - if (reposToShow.length > 100) { - reposToShow = reposToShow.splice(0, 100); - } reposToShow.sort((a, b) => b.text .toString() .replace(/\d+/g, (n) => +n + 1000) .localeCompare(a.text.toString().replace(/\d+/g, (n) => +n + 1000)) ); + + if (reposToShow.length > 100) { + reposToShow = reposToShow.splice(0, 100); + } return this._getDropDownView(triggerId, reposToShow); } } From 139d0072946f5001687905d58e23be94a6532dfb Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 12:08:05 -0500 Subject: [PATCH 07/12] DOP-4356 just implement reverse and splice --- src/services/slack.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index b59a44347..ccffe4378 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -194,12 +194,7 @@ export class SlackConnector implements ISlackConnector { // THis is the limitation enforced by slack as no more 100 items are allowd in the dropdown //'[ERROR] no more than 100 items allowed [json-pointer:/view/blocks/0/element/options]' - reposToShow.sort((a, b) => - b.text - .toString() - .replace(/\d+/g, (n) => +n + 1000) - .localeCompare(a.text.toString().replace(/\d+/g, (n) => +n + 1000)) - ); + reposToShow.sort().reverse(); if (reposToShow.length > 100) { reposToShow = reposToShow.splice(0, 100); From 88f205b038cfc0a1ba22cbd513e549feb78cfba9 Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 13:14:12 -0500 Subject: [PATCH 08/12] DOP-4356 retrying sort accurately --- src/services/slack.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index ccffe4378..1bb1af537 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -194,7 +194,14 @@ export class SlackConnector implements ISlackConnector { // THis is the limitation enforced by slack as no more 100 items are allowd in the dropdown //'[ERROR] no more than 100 items allowed [json-pointer:/view/blocks/0/element/options]' - reposToShow.sort().reverse(); + reposToShow + .sort((a, b) => + a.text + .toString() + .replace(/\d+/g, (n) => +n + 1000) + .localeCompare(b.text.toString().replace(/\d+/g, (n) => +n + 1000)) + ) + .reverse(); if (reposToShow.length > 100) { reposToShow = reposToShow.splice(0, 100); From ad6bd4f77103674392a966032622330d7c04c11d Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 14:13:46 -0500 Subject: [PATCH 09/12] DOP-4356 retrying sort accurately --- src/services/slack.ts | 16 ++++++++-------- tests/unit/api/slack.test.ts | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index 1bb1af537..ea0b4542f 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -194,14 +194,14 @@ export class SlackConnector implements ISlackConnector { // THis is the limitation enforced by slack as no more 100 items are allowd in the dropdown //'[ERROR] no more than 100 items allowed [json-pointer:/view/blocks/0/element/options]' - reposToShow - .sort((a, b) => - a.text - .toString() - .replace(/\d+/g, (n) => +n + 1000) - .localeCompare(b.text.toString().replace(/\d+/g, (n) => +n + 1000)) - ) - .reverse(); + reposToShow.sort((a, b) => { + return b.value + .toString() + .replace(/\d+/g, (n) => +n + 100000) + .localeCompare(a.value.toString().replace(/\d+/g, (n) => +n + 100000)); + }); + + console.log('hello', reposToShow); if (reposToShow.length > 100) { reposToShow = reposToShow.splice(0, 100); diff --git a/tests/unit/api/slack.test.ts b/tests/unit/api/slack.test.ts index 2b0cda063..d7837be61 100644 --- a/tests/unit/api/slack.test.ts +++ b/tests/unit/api/slack.test.ts @@ -53,6 +53,7 @@ jest.mock('../../../src/repositories/docsetsRepository', () => ({ jest.mock('config'); describe('Slack API Controller Tests', () => { + console.log('hello'); const mockEntitlement = { email: 'test.user@mongodb.com', github_username: 'test.user', From 6dd843b1d86015877fee392c646e790e069e2a50 Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 14:52:18 -0500 Subject: [PATCH 10/12] DOP-4356 trying other splicing --- src/services/slack.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index ea0b4542f..1f60e2ad4 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -191,21 +191,21 @@ export class SlackConnector implements ISlackConnector { }; reposToShow.push(opt); }); + // THis is the limitation enforced by slack as no more 100 items are allowd in the dropdown //'[ERROR] no more than 100 items allowed [json-pointer:/view/blocks/0/element/options]' + if (reposToShow.length > 100) { + reposToShow = reposToShow.sort().reverse().splice(0, 100); + } + reposToShow.sort((a, b) => { - return b.value + return b.text.text .toString() .replace(/\d+/g, (n) => +n + 100000) - .localeCompare(a.value.toString().replace(/\d+/g, (n) => +n + 100000)); + .localeCompare(a.text.text.toString().replace(/\d+/g, (n) => +n + 100000)); }); - console.log('hello', reposToShow); - - if (reposToShow.length > 100) { - reposToShow = reposToShow.splice(0, 100); - } return this._getDropDownView(triggerId, reposToShow); } } From e87d10f16b43dc8aaec71a08ce2f8f5100f205b9 Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 15:15:26 -0500 Subject: [PATCH 11/12] DOP-4356 update comments, remove from preprd --- .github/workflows/deploy-stg-ecs.yml | 1 - src/services/slack.ts | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-stg-ecs.yml b/.github/workflows/deploy-stg-ecs.yml index d25a9ea27..2967c5812 100644 --- a/.github/workflows/deploy-stg-ecs.yml +++ b/.github/workflows/deploy-stg-ecs.yml @@ -3,7 +3,6 @@ on: branches: - "main" - "integration" - - "DOP-4356" concurrency: group: environment-stg-${{ github.ref }} cancel-in-progress: true diff --git a/src/services/slack.ts b/src/services/slack.ts index 1f60e2ad4..58cb01246 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -193,12 +193,14 @@ export class SlackConnector implements ISlackConnector { }); // THis is the limitation enforced by slack as no more 100 items are allowd in the dropdown + //Sort the list so that any inactive versions are at the end and will be truncated if any items must be truncated //'[ERROR] no more than 100 items allowed [json-pointer:/view/blocks/0/element/options]' if (reposToShow.length > 100) { reposToShow = reposToShow.sort().reverse().splice(0, 100); } + //sort versions like so: 4.1, 4.2, 4.11 reposToShow.sort((a, b) => { return b.text.text .toString() From f65fcb0261d3faf146a1ab586fe66f72a85c4fd4 Mon Sep 17 00:00:00 2001 From: Anabella Buckvar Date: Thu, 8 Feb 2024 16:04:07 -0500 Subject: [PATCH 12/12] DOP-4356 cleanup --- src/services/slack.ts | 2 +- tests/unit/api/slack.test.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/services/slack.ts b/src/services/slack.ts index 58cb01246..4370a8500 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -192,7 +192,7 @@ export class SlackConnector implements ISlackConnector { reposToShow.push(opt); }); - // THis is the limitation enforced by slack as no more 100 items are allowd in the dropdown + // This is the limitation enforced by slack as no more 100 items are allowd in the dropdown //Sort the list so that any inactive versions are at the end and will be truncated if any items must be truncated //'[ERROR] no more than 100 items allowed [json-pointer:/view/blocks/0/element/options]' diff --git a/tests/unit/api/slack.test.ts b/tests/unit/api/slack.test.ts index d7837be61..2b0cda063 100644 --- a/tests/unit/api/slack.test.ts +++ b/tests/unit/api/slack.test.ts @@ -53,7 +53,6 @@ jest.mock('../../../src/repositories/docsetsRepository', () => ({ jest.mock('config'); describe('Slack API Controller Tests', () => { - console.log('hello'); const mockEntitlement = { email: 'test.user@mongodb.com', github_username: 'test.user',