Skip to content

Commit eae51cd

Browse files
Merge pull request #358 from bountyC0d3r/develop
use the new API to get all the groupIds
2 parents a9ac3d3 + 9a073bd commit eae51cd

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

src/services/groups.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -320,33 +320,15 @@ class GroupService {
320320
* @return {Promise} Resolves to ID array.
321321
*/
322322
async getGroupTreeIds(rootGroupId, maxage = 5 * 60 * 1000) {
323-
//TODO: Once the fix is validated and working, remove all commented code related to caching
324-
/**
325-
* Removing the caching mechanism,
326-
* as the group created on the day will only be pickedup on the next day
327-
* and stored in the cache
328-
*/
329-
// const now = Date.now();
330-
// const cache = this.private.cache.groupTreeIds;
331323

332-
/* Clean-up: removes stale records from the cache. */
333-
// const CLEAN_UP_INTERVAL = 24 * 60 * 60 * 1000; // 1 day in ms.
334-
// if (now - cache.lastCleanUp > CLEAN_UP_INTERVAL) {
335-
// _.forOwn(cache, ({ timestamp }, key) => {
336-
// if (now - timestamp > CLEAN_UP_INTERVAL) delete cache[key];
337-
// });
338-
// cache.lastCleanUp = now;
339-
// }
324+
let url = `/groups/${rootGroupId}?flattenGroupIdTree=true`;
325+
const response = await this.private.api.get(url);
326+
const responseJSON = handleApiResponse(response);
340327

341-
/* If result is found in cache, and is fresh enough, return it. */
342-
// const cached = cache[rootGroupId];
343-
// if (cached && now - cached.timestamp < maxage) return _.clone(cached.data);
328+
const treeIds = responseJSON.flattenGroupIdTree
329+
treeIds.push(rootGroupId)
344330

345-
/* Otherwise, fetch result from the API, write it to the cache, and
346-
* finally return that. */
347-
const res = reduceGroupIds(await this.getGroup(rootGroupId));
348-
// cache[rootGroupId] = { data: res, timestamp: now };
349-
return _.clone(res);
331+
return treeIds;
350332
}
351333

352334
/**

0 commit comments

Comments
 (0)