Skip to content

update topcoder-react-lib and community-app for topgear submit URL issue #360

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

Closed
wants to merge 9 commits into from
Next Next commit
use the new API to get all the groupIds
  • Loading branch information
bountyC0d3r committed Feb 16, 2023
commit 9a073bd44c861f44a8905a5e5adc96fff6c2397d
30 changes: 6 additions & 24 deletions src/services/groups.js
Original file line number Diff line number Diff line change
@@ -320,33 +320,15 @@ class GroupService {
* @return {Promise} Resolves to ID array.
*/
async getGroupTreeIds(rootGroupId, maxage = 5 * 60 * 1000) {
//TODO: Once the fix is validated and working, remove all commented code related to caching
/**
* Removing the caching mechanism,
* as the group created on the day will only be pickedup on the next day
* and stored in the cache
*/
// const now = Date.now();
// const cache = this.private.cache.groupTreeIds;

/* 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;
// }
let url = `/groups/${rootGroupId}?flattenGroupIdTree=true`;
const response = await this.private.api.get(url);
const responseJSON = 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(rootGroupId)

/* 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;
}

/**