From a48e493792d4fe9161f8b83d6bdad4119292aa13 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 26 Oct 2023 16:00:04 +0300 Subject: [PATCH] Change caching time --- src/services/creatorStaking/creatorsList.ts | 6 +++--- src/services/creatorStaking/creatorsSpaces.ts | 5 +++-- src/services/creatorStaking/index.ts | 2 +- src/services/creatorStaking/stakingConsts.ts | 6 ++++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/services/creatorStaking/creatorsList.ts b/src/services/creatorStaking/creatorsList.ts index eec3666..720ac88 100644 --- a/src/services/creatorStaking/creatorsList.ts +++ b/src/services/creatorStaking/creatorsList.ts @@ -1,9 +1,9 @@ import { CreatorStakingProps } from "." import Cache from "../../cache" -import { ONE_HOUR } from "../../constant" +import { FIVE_MINUTES } from "../../constant" import { parseStringValue } from "../utils" -type RegisteredStatus = 'Active' | 'Inactive' +type RegisteredStatus = 'Active' | Record<'Inactive', string> type RegisteredCreator = { spaceId: string @@ -11,7 +11,7 @@ type RegisteredCreator = { status: RegisteredStatus } -const creatorsListCache = new Cache('creators-list', ONE_HOUR) +const creatorsListCache = new Cache('creators-list', FIVE_MINUTES) export const getCreatorsList = async ({ apis diff --git a/src/services/creatorStaking/creatorsSpaces.ts b/src/services/creatorStaking/creatorsSpaces.ts index ab381c7..77ae859 100644 --- a/src/services/creatorStaking/creatorsSpaces.ts +++ b/src/services/creatorStaking/creatorsSpaces.ts @@ -1,9 +1,9 @@ import { gql } from 'graphql-request' import Cache from '../../cache' -import { ONE_HOUR } from '../../constant' +import { FIVE_MINUTES } from '../../constant' import { subsocialGraphQlClient } from '../../constant/graphQlClients' -const creatorsSpacesCache = new Cache('creators-spaces', ONE_HOUR) +const creatorsSpacesCache = new Cache('creators-spaces', FIVE_MINUTES) type CreatorsSpacesInfo = { spaceIds: string[] @@ -18,6 +18,7 @@ export const GET_CREATORS_SPACES = gql` name about email + postsCount linksOriginal ownedByAccount { id diff --git a/src/services/creatorStaking/index.ts b/src/services/creatorStaking/index.ts index 45da2cb..c12206e 100644 --- a/src/services/creatorStaking/index.ts +++ b/src/services/creatorStaking/index.ts @@ -155,7 +155,7 @@ export const getBackerRewards = async ({ account, spaceIds }: StakerRewardsProps rewardsBySpaceId[spaceId] = rewards }) - availableClaimResult.forEach(([spaceId, claimCount]) => { + availableClaimResult?.forEach(([spaceId, claimCount]) => { availableClaimsBySpaceId[spaceId] = claimCount }) diff --git a/src/services/creatorStaking/stakingConsts.ts b/src/services/creatorStaking/stakingConsts.ts index 2f7e8a1..0ce5c18 100644 --- a/src/services/creatorStaking/stakingConsts.ts +++ b/src/services/creatorStaking/stakingConsts.ts @@ -1,8 +1,8 @@ import { CreatorStakingProps } from "." import Cache from "../../cache" -import { ONE_HOUR } from "../../constant" +import { FIVE_MINUTES } from "../../constant" -const stakingConstsCache = new Cache('creator-consts', ONE_HOUR * 24) +const stakingConstsCache = new Cache('creator-consts', FIVE_MINUTES) export const getStakingConsts = async ({ apis }: CreatorStakingProps) => { const api = apis.subsocial @@ -21,6 +21,7 @@ export const getStakingConsts = async ({ apis }: CreatorStakingProps) => { const maxNumberOfStakersPerCreator = api.consts.creatorStaking.maxNumberOfBackersPerCreator.toJSON() const maxEraStakeValues = api.consts.creatorStaking.maxEraStakeItems.toJSON() + const blocksPerEra = api.consts.creatorStaking.blockPerEra.toJSON() const currentAnnualInflation = api.consts.creatorStaking.annualInflation.toHuman() as string @@ -30,6 +31,7 @@ export const getStakingConsts = async ({ apis }: CreatorStakingProps) => { minimumRemainingAmount, maxNumberOfStakersPerCreator, maxEraStakeValues, + blocksPerEra, currentAnnualInflation: currentAnnualInflation.replace('%', '') }) }