Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
fix(caching): No need to load the cache on start (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
JForsaken authored Apr 29, 2022
1 parent ccc4d73 commit 3055589
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation
import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { Network } from '~types/network.interface';

import { PoolTogetherAirdropTokenBalancesHelper } from '../helpers/pool-together.airdrop.balance-helper';
import { PoolTogetherClaimableTokenBalancesHelper } from '../helpers/pool-together-v3.claimable.balance-helper';
import { PoolTogetherAirdropTokenBalancesHelper } from '../helpers/pool-together.airdrop.balance-helper';
import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

@Register.BalanceFetcher(POOL_TOGETHER_DEFINITION.id, Network.AVALANCHE_MAINNET)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Inject } from '@nestjs/common';
import { BigNumber } from 'ethers';
import { sum } from 'lodash';

import { Register } from '~app-toolkit/decorators';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { TvlFetcher } from '~stats/tvl/tvl-fetcher.interface';
import { Network } from '~types/network.interface';

import { PoolTogetherContractFactory } from '../contracts';
import { PoolTogetherApiPrizePoolRegistry } from '../helpers/pool-together.api.prize-pool-registry';

import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

const appId = POOL_TOGETHER_DEFINITION.id;
Expand Down
3 changes: 1 addition & 2 deletions src/apps/pool-together/celo/pool-together.tvl-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Inject } from '@nestjs/common';
import { BigNumber } from 'ethers';
import { sum } from 'lodash';

import { Register } from '~app-toolkit/decorators';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { TvlFetcher } from '~stats/tvl/tvl-fetcher.interface';
import { Network } from '~types/network.interface';

import { PoolTogetherContractFactory } from '../contracts';
import { PoolTogetherApiPrizePoolRegistry } from '../helpers/pool-together.api.prize-pool-registry';

import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

const appId = POOL_TOGETHER_DEFINITION.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation
import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { Network } from '~types/network.interface';

import { PoolTogetherAirdropTokenBalancesHelper } from '../helpers/pool-together.airdrop.balance-helper';
import { PoolTogetherClaimableTokenBalancesHelper } from '../helpers/pool-together-v3.claimable.balance-helper';
import { PoolTogetherAirdropTokenBalancesHelper } from '../helpers/pool-together.airdrop.balance-helper';
import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

@Register.BalanceFetcher(POOL_TOGETHER_DEFINITION.id, Network.ETHEREUM_MAINNET)
Expand Down
3 changes: 1 addition & 2 deletions src/apps/pool-together/ethereum/pool-together.tvl-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Inject } from '@nestjs/common';
import { BigNumber } from 'ethers';
import { sum } from 'lodash';

import { Register } from '~app-toolkit/decorators';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { TvlFetcher } from '~stats/tvl/tvl-fetcher.interface';
import { Network } from '~types/network.interface';

import { PoolTogetherContractFactory } from '../contracts';
import { PoolTogetherApiPrizePoolRegistry } from '../helpers/pool-together.api.prize-pool-registry';

import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

const appId = POOL_TOGETHER_DEFINITION.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { ContractType } from '~position/contract.interface';
import { AppTokenPosition } from '~position/position.interface';
import { AppGroupsDefinition } from '~position/position.service';
import { Network } from '~types/network.interface';
import { PoolTogetherContractFactory } from '../contracts';

import { PoolTogetherContractFactory } from '../contracts';
import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

import { V3PrizePool } from './pool-together.api.prize-pool-registry';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Injectable } from '@nestjs/common';
import Axios from 'axios';

import { Network, NETWORK_IDS } from '~types/network.interface';

export type V4PrizePool = {
Expand Down
3 changes: 1 addition & 2 deletions src/apps/pool-together/polygon/pool-together.tvl-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Inject } from '@nestjs/common';
import { BigNumber } from 'ethers';
import { sum } from 'lodash';

import { Register } from '~app-toolkit/decorators';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { TvlFetcher } from '~stats/tvl/tvl-fetcher.interface';
import { Network } from '~types/network.interface';

import { PoolTogetherContractFactory } from '../contracts';
import { PoolTogetherApiPrizePoolRegistry } from '../helpers/pool-together.api.prize-pool-registry';

import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

const appId = POOL_TOGETHER_DEFINITION.id;
Expand Down
20 changes: 10 additions & 10 deletions src/apps/pool-together/pool-together.module.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { Register } from '~app-toolkit/decorators';
import { AbstractApp } from '~app/app.dynamic-module';

import { AvalanchePoolTogetherV4TicketTokenFetcher } from './avalanche/pool-together.v4-ticket.token-fetcher';
import { AvalanchePoolTogetherBalanceFetcher } from './avalanche/pool-together.balance-fetcher';
import { AvalanchePoolTogetherTvlFetcher } from './avalanche/pool-together.tvl-fetcher';
import { AvalanchePoolTogetherV4TicketTokenFetcher } from './avalanche/pool-together.v4-ticket.token-fetcher';
import { CeloPoolTogetherBalanceFetcher } from './celo/pool-together.balance-fetcher';
import { CeloPoolTogetherTvlFetcher } from './celo/pool-together.tvl-fetcher';
import { CeloPoolTogetherV3TicketTokenFetcher } from './celo/pool-together.v3-ticket.token-fetcher';
import { PoolTogetherContractFactory } from './contracts';
import { EthereumPoolTogetherV4TicketTokenFetcher } from './ethereum/pool-together.v4-ticket.token-fetcher';
import { EthereumPoolTogetherBalanceFetcher } from './ethereum/pool-together.balance-fetcher';
import { EthereumPoolTogetherTvlFetcher } from './ethereum/pool-together.tvl-fetcher';
import { EthereumPoolTogetherPodTokenFetcher } from './ethereum/pool-together.v3-pod.token-fetcher';
import { EthereumPoolTogetherV3TicketTokenFetcher } from './ethereum/pool-together.v3-ticket.token-fetcher';
import { PoolTogetherV4PrizePoolTokenHelper } from './helpers/pool-together-v4.prize-pool.token-helper';
import { PoolTogetherAirdropTokenBalancesHelper } from './helpers/pool-together.airdrop.balance-helper';
import { EthereumPoolTogetherV4TicketTokenFetcher } from './ethereum/pool-together.v4-ticket.token-fetcher';
import { PoolTogetherClaimableTokenBalancesHelper } from './helpers/pool-together-v3.claimable.balance-helper';
import { PoolTogetherFaucetAddressHelper } from './helpers/pool-together-v3.faucet.address-helper';
import { PoolTogetherV3PodTokenHelper } from './helpers/pool-together-v3.pod.token-helper';
import { PoolTogetherV3PrizePoolTokenHelper } from './helpers/pool-together-v3.prize-pool.token-helper';
import { PolygonPoolTogetherV4TicketTokenFetcher } from './polygon/pool-together.v4-ticket.token-fetcher';
import { PolygonPoolTogetherBalanceFetcher } from './polygon/pool-together.balance-fetcher';
import { PolygonPoolTogetherV3TicketTokenFetcher } from './polygon/pool-together.v3-ticket.token-fetcher';
import { PoolTogetherV4PrizePoolTokenHelper } from './helpers/pool-together-v4.prize-pool.token-helper';
import { PoolTogetherAirdropTokenBalancesHelper } from './helpers/pool-together.airdrop.balance-helper';
import { PoolTogetherApiPrizePoolRegistry } from './helpers/pool-together.api.prize-pool-registry';
import { PolygonPoolTogetherBalanceFetcher } from './polygon/pool-together.balance-fetcher';
import { PolygonPoolTogetherTvlFetcher } from './polygon/pool-together.tvl-fetcher';
import { EthereumPoolTogetherTvlFetcher } from './ethereum/pool-together.tvl-fetcher';
import { CeloPoolTogetherTvlFetcher } from './celo/pool-together.tvl-fetcher';
import { AvalanchePoolTogetherTvlFetcher } from './avalanche/pool-together.tvl-fetcher';
import { PolygonPoolTogetherV3TicketTokenFetcher } from './polygon/pool-together.v3-ticket.token-fetcher';
import { PolygonPoolTogetherV4TicketTokenFetcher } from './polygon/pool-together.v4-ticket.token-fetcher';
import POOL_TOGETHER_DEFINITION, { PoolTogetherAppDefinition } from './pool-together.definition';

@Register.AppModule({
Expand Down
4 changes: 1 addition & 3 deletions src/cache/cache-on-interval.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ export class CacheOnIntervalService implements OnModuleInit, OnModuleDestroy {
@Inject(Reflector) private readonly reflector: Reflector,
) {}

async onModuleInit() {
await this.cacheManager.load();

onModuleInit() {
const instanceWrappers = this.discoveryService.getProviders();
instanceWrappers
.filter(wrapper => wrapper.isDependencyTreeStatic() && !!wrapper.instance)
Expand Down
4 changes: 1 addition & 3 deletions src/cache/cache.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export class CacheService implements OnModuleInit {
@Inject(Reflector) private readonly reflector: Reflector,
) {}

async onModuleInit() {
await this.cacheManager.load();

onModuleInit() {
const instanceWrappers = this.discoveryService.getProviders();
instanceWrappers
.filter(wrapper => wrapper.isDependencyTreeStatic() && !!wrapper.instance)
Expand Down

0 comments on commit 3055589

Please sign in to comment.