Skip to content

Commit

Permalink
Remove cache info
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Mar 6, 2023
1 parent 7648dcb commit cc03d8c
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 52 deletions.
10 changes: 7 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@golevelup/nestjs-rabbitmq": "3.4.0",
"@multiversx/sdk-core": "11.2.0",
"@multiversx/sdk-native-auth-server": "1.0.5",
"@multiversx/sdk-nestjs": "0.3.8",
"@multiversx/sdk-nestjs": "0.3.9",
"@multiversx/sdk-network-providers": "^1.2.1",
"@nestjs/apollo": "^10.1.7",
"@nestjs/common": "9.1.4",
Expand Down
1 change: 0 additions & 1 deletion src/common/models/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { envload } from './env_load';
envload();
import * as config from 'config';
import { CachingConfig } from '../common/models';

/**
* Wallet object configuration.
Expand All @@ -12,7 +11,6 @@ export const mxConfig = config.get('multiversX');
* Caching time config.
* The values are in seconds
*/
export const cacheConfig: CachingConfig = config.get('caching');

export const fileStorage = config.get('fileStorage');
export const gas = config.get('gas');
Expand Down
2 changes: 0 additions & 2 deletions src/crons/cache.warmer/auctions.warmer.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { CacheInfo } from 'src/common/services/caching/entities/cache.info';
import { cacheConfig } from 'src/config';
import { ClientProxy } from '@nestjs/microservices';
import { CachingService, Constants, Locker } from '@multiversx/sdk-nestjs';

Expand Down Expand Up @@ -130,7 +129,6 @@ export class AuctionsWarmerService {
await this.clientProxy.emit('refreshCacheKey', {
key,
ttl,
redisClientName: cacheConfig.auctionsRedisClientName,
});
}
}
4 changes: 1 addition & 3 deletions src/crons/cache.warmer/collections.warmer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Cron, CronExpression } from '@nestjs/schedule';
import * as Redis from 'ioredis';
import { CacheInfo } from 'src/common/services/caching/entities/cache.info';
import { ClientProxy } from '@nestjs/microservices';
import { cacheConfig } from 'src/config';
import { CachingService, Constants, Locker } from '@multiversx/sdk-nestjs';
import { CachingService, Locker } from '@multiversx/sdk-nestjs';

import { CollectionsGetterService } from 'src/modules/nftCollections/collections-getter.service';

Expand Down Expand Up @@ -114,7 +113,6 @@ export class CollectionsWarmerService {
key: string;
ttl: number;
}>('refreshCacheKey', {
redisClientName: cacheConfig.collectionsRedisClientName,
key,
ttl,
});
Expand Down
2 changes: 0 additions & 2 deletions src/crons/cache.warmer/likes.warmer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Cron, CronExpression } from '@nestjs/schedule';
import * as Redis from 'ioredis';
import { CacheInfo } from 'src/common/services/caching/entities/cache.info';
import { ClientProxy } from '@nestjs/microservices';
import { cacheConfig } from 'src/config';
import { CachingService, Locker } from '@multiversx/sdk-nestjs';
import { AssetsLikesService } from 'src/modules/assets';

Expand Down Expand Up @@ -42,7 +41,6 @@ export class LikesWarmerService {
key: string;
ttl: number;
}>('refreshCacheKey', {
redisClientName: cacheConfig.persistentRedisClientName,
key,
ttl,
});
Expand Down
2 changes: 0 additions & 2 deletions src/crons/cache.warmer/tokens.warmer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { CacheInfo } from 'src/common/services/caching/entities/cache.info';
import { ClientProxy } from '@nestjs/microservices';
import { cacheConfig } from 'src/config';
import { MxApiService } from 'src/common';
import { CachingService, Locker } from '@multiversx/sdk-nestjs';

Expand Down Expand Up @@ -72,7 +71,6 @@ export class TokensWarmerService {
key: string;
ttl: number;
}>('refreshCacheKey', {
redisClientName: cacheConfig.persistentRedisClientName,
key,
ttl,
});
Expand Down
2 changes: 0 additions & 2 deletions src/crons/cache.warmer/trendingCollections.warmer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Inject, Injectable } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { CacheInfo } from 'src/common/services/caching/entities/cache.info';
import { ClientProxy } from '@nestjs/microservices';
import { cacheConfig } from 'src/config';
import { AnalyticsService } from 'src/modules/analytics/analytics.service';
import { CachingService, Locker } from '@multiversx/sdk-nestjs';

Expand Down Expand Up @@ -43,7 +42,6 @@ export class TrendingCollectionsWarmerService {
key: string;
ttl: number;
}>('refreshCacheKey', {
redisClientName: cacheConfig.collectionsRedisClientName,
key,
ttl,
});
Expand Down
3 changes: 1 addition & 2 deletions src/crons/elastic.updater/rarity.updater.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable, Logger } from '@nestjs/common';
import { MxElasticService } from 'src/common';
import { NftRarityService } from 'src/modules/nft-rarity/nft-rarity.service';
import { cacheConfig } from 'src/config';
import { generateCacheKeyFromParams } from 'src/utils/generate-cache-key';
import { NftRarityElasticService } from 'src/modules/nft-rarity/nft-rarity.elastic.service';
import { Locker, RedisCacheService } from '@multiversx/sdk-nestjs';
Expand Down Expand Up @@ -141,6 +140,6 @@ export class RarityUpdaterService {
}

private getRarityQueueCacheKey() {
return generateCacheKeyFromParams(cacheConfig.rarityQueueClientName);
return generateCacheKeyFromParams('rarityQueue');
}
}
5 changes: 1 addition & 4 deletions src/crons/elastic.updater/traits.updater.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Injectable, Logger } from '@nestjs/common';
import { MxElasticService } from 'src/common';
import { cacheConfig } from 'src/config';
import { generateCacheKeyFromParams } from 'src/utils/generate-cache-key';

import { NftTraitsService } from 'src/modules/nft-traits/nft-traits.service';
Expand All @@ -15,15 +14,13 @@ import {
getCollectionsWhereTraitsFlagNotSetFromElasticQuery,
getCollectionsWithTraitSummaryFromElasticQuery,
} from 'src/modules/nft-traits/nft-traits.elastic.queries';
import { NftTraitsElasticService } from 'src/modules/nft-traits/nft-traits.elastic.service';

@Injectable()
export class TraitsUpdaterService {
constructor(
private readonly nftTraitsService: NftTraitsService,
private readonly redisCacheService: RedisCacheService,
private readonly elasticService: MxElasticService,
private readonly nftTraitsElasticService: NftTraitsElasticService,
private readonly logger: Logger,
) {}

Expand Down Expand Up @@ -214,7 +211,7 @@ export class TraitsUpdaterService {
}

private getTraitsQueueCacheKey() {
return generateCacheKeyFromParams(cacheConfig.traitsQueueClientName);
return generateCacheKeyFromParams('traitsQueue');
}

private getTraitsValidatorCounterCacheKey() {
Expand Down
9 changes: 3 additions & 6 deletions src/modules/analytics/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import BigNumber from 'bignumber.js';
import { BuyEventParser } from './buy-event.parser';
import { UsdPriceService } from '../usdPrice/usd-price.service';
import { computeUsd } from 'src/utils/helpers';
import * as Redis from 'ioredis';
import { cacheConfig } from 'src/config';
import { CacheInfo } from 'src/common/services/caching/entities/cache.info';
import { AcceptOfferEventParser } from './acceptOffer-event.parser';
import { CollectionVolumeLast24 } from './collection-volume';
Expand All @@ -19,7 +17,6 @@ import { CachingService } from '@multiversx/sdk-nestjs';
export class AnalyticsService {
private filterAddresses: string[];
private data: any[] = [];
private redisClient: Redis.Redis;

constructor(
private readonly indexerService: ElasticAnalyticsService,
Expand Down Expand Up @@ -115,7 +112,7 @@ export class AnalyticsService {
tokens: collection.tokens,
});
}
return trending.sortedDescending([(x) => parseFloat(x.volume)]);
return trending.sortedDescending((x) => parseFloat(x.volume));
}

private async getParsedEvents(
Expand Down Expand Up @@ -175,8 +172,8 @@ export class AnalyticsService {
.groupBy((g: { paymentToken: any }) => g.paymentToken, true)
.map((group: { key: any; values: any[] }) => ({
paymentToken: group.key,
sum: group.values.sumBigInt(
(x: { value:BigInt }) => BigInt(x.value.toString()),
sum: group.values.sumBigInt((x: { value: BigInt }) =>
BigInt(x.value.toString()),
),
})),
}));
Expand Down
2 changes: 1 addition & 1 deletion src/modules/assets/assets-transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@multiversx/sdk-core';
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
import { MxApiService, getSmartContract } from 'src/common';
import { cacheConfig, mxConfig, gas } from 'src/config';
import { mxConfig, gas } from 'src/config';
import {
getCollectionAndNonceFromIdentifier,
timestampToEpochAndRound,
Expand Down
36 changes: 21 additions & 15 deletions src/modules/auctions/auctions-getter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CachingService } from '@multiversx/sdk-nestjs';
import { PriceRange } from 'src/db/auctions/price-range';
import { AuctionsCachingService } from './caching/auctions-caching.service';
import { Constants } from '@multiversx/sdk-nestjs';
import { cacheConfig, mxConfig } from 'src/config';
import { mxConfig } from 'src/config';
import { AuctionCustomEnum } from '../common/filters/AuctionCustomFilters';
import { PersistenceService } from 'src/common/persistence/persistence.service';
import { Token } from 'src/common/services/mx-communication/models/Token.model';
Expand Down Expand Up @@ -335,12 +335,14 @@ export class AuctionsGetterService {
if (sort) {
if (sort.direction === Sort.ASC) {
if (sort.field === 'endDate') {
allAuctions = allAuctions.sorted([(x) => x[sort.field]], true);
allAuctions = allAuctions.sorted((x) =>
x[sort.field] === 0 ? Number.MAX_SAFE_INTEGER : x[sort.field],
);
} else {
allAuctions = allAuctions.sorted([(x) => x[sort.field]]);
allAuctions = allAuctions.sorted((x) => x[sort.field]);
}
} else {
allAuctions = allAuctions.sortedDescending([(x) => x[sort.field]]);
allAuctions = allAuctions.sortedDescending((x) => x[sort.field]);
}
}

Expand Down Expand Up @@ -419,12 +421,14 @@ export class AuctionsGetterService {
if (sort) {
if (sort.direction === Sort.ASC) {
if (sort.field === 'endDate') {
allAuctions = allAuctions.sorted([(x) => x[sort.field]], true);
allAuctions = allAuctions.sorted((x) =>
x[sort.field] === 0 ? Number.MAX_SAFE_INTEGER : x[sort.field],
);
} else {
allAuctions = allAuctions.sorted([(x) => x[sort.field]]);
allAuctions = allAuctions.sorted((x) => x[sort.field]);
}
} else {
allAuctions = allAuctions.sortedDescending([(x) => x[sort.field]]);
allAuctions = allAuctions.sortedDescending((x) => x[sort.field]);
}
}

Expand Down Expand Up @@ -470,9 +474,9 @@ export class AuctionsGetterService {
}
if (currentPriceSort) {
if (currentPriceSort.direction === Sort.ASC) {
allAuctions = allAuctions.sorted([(x) => x['startBid']]);
allAuctions = allAuctions.sorted((x) => x['startBid']);
} else {
allAuctions = allAuctions.sortedDescending([(x) => x['startBid']]);
allAuctions = allAuctions.sortedDescending((x) => x['startBid']);
}
}
}
Expand All @@ -494,12 +498,12 @@ export class AuctionsGetterService {
if (sort) {
if (sort.direction === Sort.ASC) {
if (sort.field === 'endDate') {
allAuctions = allAuctions.sorted([(x) => x[sort.field]]);
allAuctions = allAuctions.sorted((x) => x[sort.field]);
} else {
allAuctions = allAuctions.sorted([(x) => x[sort.field]]);
allAuctions = allAuctions.sorted((x) => x[sort.field]);
}
} else {
allAuctions = allAuctions.sortedDescending([(x) => x[sort.field]]);
allAuctions = allAuctions.sortedDescending((x) => x[sort.field]);
}
}

Expand Down Expand Up @@ -527,12 +531,14 @@ export class AuctionsGetterService {
if (sort) {
if (sort.direction === Sort.ASC) {
if (sort.field === 'endDate') {
allAuctions = allAuctions.sorted([(x) => x[sort.field]], true);
allAuctions = allAuctions.sorted((x) =>
x[sort.field] === 0 ? Number.MAX_SAFE_INTEGER : x[sort.field],
);
} else {
allAuctions = allAuctions.sorted([(x) => x[sort.field]]);
allAuctions = allAuctions.sorted((x) => x[sort.field]);
}
} else {
allAuctions = allAuctions.sortedDescending([(x) => x[sort.field]]);
allAuctions = allAuctions.sortedDescending((x) => x[sort.field]);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/modules/campaigns/campaigns.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { CampaignEntity } from 'src/db/campaigns';
import { NftMinterAbiService } from './nft-minter.abi.service';
import { CampaignsFilter } from '../common/filters/filtersTypes';
import { CollectionType } from '../assets/models/Collection.type';
import { cacheConfig } from 'src/config';
import { CachingService, Constants } from '@multiversx/sdk-nestjs';
import { CacheInfo } from 'src/common/services/caching/entities/cache.info';
import { ClientProxy } from '@nestjs/microservices';
Expand Down Expand Up @@ -132,7 +131,6 @@ export class CampaignsService {
this.clientProxy.emit('refreshCacheKey', {
key,
ttl,
redisClientName: cacheConfig.persistentRedisClientName,
});
}

Expand Down
1 change: 0 additions & 1 deletion src/modules/explore-stats/explore-stats.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Injectable } from '@nestjs/common';
import { MxApiService } from 'src/common';
import { cacheConfig } from 'src/config';
import { CollectionsGetterService } from '../nftCollections/collections-getter.service';
import {
ExploreCollectionsStats,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Injectable } from '@nestjs/common';
import { MxApiService } from 'src/common';
import { cacheConfig } from 'src/config';
import { FlagNftService } from 'src/modules/admins/flag-nft.service';
import { AssetByIdentifierService } from 'src/modules/assets';
import { Asset, NftEventEnum, NftTypeEnum } from 'src/modules/assets/models';
Expand Down Expand Up @@ -204,7 +203,7 @@ export class ElasticUpdatesEventsService {
}

private getRarityQueueCacheKey() {
return generateCacheKeyFromParams(cacheConfig.rarityQueueClientName);
return generateCacheKeyFromParams('rarityQueue');
}

async addNftsToTraitsQueue(collectionTickers: string[]): Promise<void> {
Expand All @@ -217,7 +216,7 @@ export class ElasticUpdatesEventsService {
}

private getTraitsQueueCacheKey() {
return generateCacheKeyFromParams(cacheConfig.traitsQueueClientName);
return generateCacheKeyFromParams('traitsQueue');
}

private convertToMatchingEventType(
Expand Down

0 comments on commit cc03d8c

Please sign in to comment.