From 973088866217cd9543920a955db0d28e769992d3 Mon Sep 17 00:00:00 2001 From: bountyCoder Date: Fri, 3 Mar 2023 22:59:13 +0000 Subject: [PATCH 1/3] changes for the oldId --- .circleci/config.yml | 2 +- package.json | 2 +- src/services/groups.js | 29 ++++++++++------------------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e161844..e8eac28e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,7 +28,7 @@ jobs: - attach_workspace: at: . - run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - - run: npm publish + - run: npm publish --tag test-release # dont change anything workflows: version: 2 diff --git a/package.json b/package.json index 5d0825f6..5ed38149 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .", "test": "npm run lint && npm run jest" }, - "version": "1.2.10", + "version": "1000.29.16", "dependencies": { "auth0-js": "^6.8.4", "config": "^3.2.0", diff --git a/src/services/groups.js b/src/services/groups.js index 2ba8b986..ffe68bb6 100644 --- a/src/services/groups.js +++ b/src/services/groups.js @@ -319,28 +319,19 @@ class GroupService { * cache. Defaults to 5 minutes. * @return {Promise} Resolves to ID array. */ - async getGroupTreeIds(rootGroupId, maxage = 5 * 60 * 1000) { - const now = Date.now(); - const cache = this.private.cache.groupTreeIds; + async getGroupTreeIds(rootGroupId) { + const rootGroupURL = `/groups/${rootGroupId}`; + const rootGroupRes = await this.private.api.get(rootGroupURL); + const rootGroupJSON = await handleApiResponse(rootGroupRes); - /* Clean-up: removes stale records from the cache. */ - const CLEAN_UP_INTERVAL = 24 * 60 * 60 * 1000; // 1 day in ms. - if (now - cache.lastCleanUp > CLEAN_UP_INTERVAL) { - _.forOwn(cache, ({ timestamp }, key) => { - if (now - timestamp > CLEAN_UP_INTERVAL) delete cache[key]; - }); - cache.lastCleanUp = now; - } + const url = `/groups/${rootGroupJSON.id}?flattenGroupIdTree=true`; + const response = await this.private.api.get(url); + const responseJSON = await handleApiResponse(response); - /* If result is found in cache, and is fresh enough, return it. */ - const cached = cache[rootGroupId]; - if (cached && now - cached.timestamp < maxage) return _.clone(cached.data); + const treeIds = responseJSON.flattenGroupIdTree; + treeIds.push(responseJSON.id); - /* Otherwise, fetch result from the API, write it to the cache, and - * finally return that. */ - const res = reduceGroupIds(await this.getGroup(rootGroupId)); - cache[rootGroupId] = { data: res, timestamp: now }; - return _.clone(res); + return treeIds; } /** From 492fea14f3fe8ac48fd4d49eb85d5f2bdb31ae23 Mon Sep 17 00:00:00 2001 From: bountyCoder Date: Mon, 6 Mar 2023 19:29:04 +0000 Subject: [PATCH 2/3] update for the group seq --- src/services/groups.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/groups.js b/src/services/groups.js index ffe68bb6..209a0f2b 100644 --- a/src/services/groups.js +++ b/src/services/groups.js @@ -329,7 +329,7 @@ class GroupService { const responseJSON = await handleApiResponse(response); const treeIds = responseJSON.flattenGroupIdTree; - treeIds.push(responseJSON.id); + treeIds.unshift(responseJSON.id); return treeIds; } From 8c9fc4952f5f5c27f390667852a59d51198181e6 Mon Sep 17 00:00:00 2001 From: Luiz Ricardo Rodrigues Date: Mon, 6 Mar 2023 16:31:42 -0300 Subject: [PATCH 3/3] ci: bump test version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5ed38149..3c345b50 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .", "test": "npm run lint && npm run jest" }, - "version": "1000.29.16", + "version": "1000.29.17", "dependencies": { "auth0-js": "^6.8.4", "config": "^3.2.0",