Skip to content

Commit

Permalink
Merge pull request polkassembly#1571 from polkassembly/feat/Analytics…
Browse files Browse the repository at this point in the history
…ForAllTracks

cache fixes
  • Loading branch information
KanishkaRajputd authored Apr 26, 2024
2 parents ff18599 + 40f06c8 commit 296c93a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pages/api/v1/trackLevelAnalytics/all-track-votes-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const getAllTrackLevelVotesAnalytics = async ({ network }: { network: string })
await Promise.allSettled(dataPromise);

if (process.env.IS_CACHING_ALLOWED == '1') {
const redisKey = generateKey({ govType: 'OpenGov', keyType: 'votesAnalytics', network, proposalType: ProposalType.REFERENDUM_V2 });
const redisKey = generateKey({ govType: 'OpenGov', keyType: 'allTrackVotesAnalytics', network, proposalType: ProposalType.REFERENDUM_V2 });
const redisData = await redisGet(redisKey);

if (redisData) {
Expand All @@ -50,7 +50,11 @@ const getAllTrackLevelVotesAnalytics = async ({ network }: { network: string })
}

if (process.env.IS_CACHING_ALLOWED == '1') {
await redisSetex(generateKey({ govType: 'OpenGov', keyType: 'votesAnalytics', network, proposalType: ProposalType.REFERENDUM_V2 }), TTL_DURATION, JSON.stringify(votes));
await redisSetex(
generateKey({ govType: 'OpenGov', keyType: 'allTrackVotesAnalytics', network, proposalType: ProposalType.REFERENDUM_V2 }),
TTL_DURATION,
JSON.stringify(votes)
);
}
return { data: { votes: votes || [] }, error: null, status: 200 };
} catch (err) {
Expand Down

0 comments on commit 296c93a

Please sign in to comment.