Skip to content
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

Change caching time #54

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/services/creatorStaking/creatorsList.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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
stakeholder: string
status: RegisteredStatus
}

const creatorsListCache = new Cache('creators-list', ONE_HOUR)
const creatorsListCache = new Cache('creators-list', FIVE_MINUTES)

export const getCreatorsList = async ({
apis
Expand Down
5 changes: 3 additions & 2 deletions src/services/creatorStaking/creatorsSpaces.ts
Original file line number Diff line number Diff line change
@@ -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[]
Expand All @@ -18,6 +18,7 @@ export const GET_CREATORS_SPACES = gql`
name
about
email
postsCount
linksOriginal
ownedByAccount {
id
Expand Down
2 changes: 1 addition & 1 deletion src/services/creatorStaking/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
6 changes: 4 additions & 2 deletions src/services/creatorStaking/stakingConsts.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -30,6 +31,7 @@ export const getStakingConsts = async ({ apis }: CreatorStakingProps) => {
minimumRemainingAmount,
maxNumberOfStakersPerCreator,
maxEraStakeValues,
blocksPerEra,
currentAnnualInflation: currentAnnualInflation.replace('%', '')
})
}
Expand Down
Loading