Skip to content

Commit

Permalink
SERVICES-1085 hybrid/partial reindexing states (items in memory and DB)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnykes authored and danielailie committed Nov 8, 2023
1 parent 2d8ac95 commit 7bf7cf0
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 126 deletions.
26 changes: 20 additions & 6 deletions src/common/persistence/persistence.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export class PersistenceService {
return await this.execute(this.saveTags.name, this.tagsRepository.saveTags(tags));
}

async saveTagsOrIgnore(tags: TagEntity[]): Promise<void> {
await this.execute(this.saveTagsOrIgnore.name, this.tagsRepository.saveTagsOrIgnore(tags));

Check warning on line 157 in src/common/persistence/persistence.service.ts

View check run for this annotation

Codecov / codecov/patch

src/common/persistence/persistence.service.ts#L157

Added line #L157 was not covered by tests
}

async getCollectionStats(
identifier: string,
marketplaceKey: string = undefined,
Expand Down Expand Up @@ -456,6 +460,13 @@ export class PersistenceService {
return await this.execute(this.getLastOrdersByAuctionIds.name, this.ordersRepository.getLastOrdersByAuctionIds(auctionIds));
}

async getOrdersByAuctionIdsGroupByAuctionId(auctionIds: number[]): Promise<any[]> {
return await this.execute(

Check warning on line 464 in src/common/persistence/persistence.service.ts

View check run for this annotation

Codecov / codecov/patch

src/common/persistence/persistence.service.ts#L464

Added line #L464 was not covered by tests
this.getOrdersByAuctionIdsGroupByAuctionId.name,
this.ordersRepository.getOrdersByAuctionIdsGroupByAuctionId(auctionIds),
);
}

async getOrdersByAuctionIds(auctionIds: number[]): Promise<any[]> {
return await this.execute(this.getOrdersByAuctionIds.name, this.ordersRepository.getOrdersByAuctionIds(auctionIds));
}
Expand All @@ -468,8 +479,8 @@ export class PersistenceService {
return await this.execute(this.saveOrder.name, this.ordersRepository.saveOrder(order));
}

async saveBulkOrders(orders: OrderEntity[]) {
return await this.execute(this.saveBulkOrders.name, this.ordersRepository.saveBulkOrders(orders));
async saveBulkOrdersOrUpdateAndFillId(orders: OrderEntity[]) {
return await this.execute(this.saveBulkOrdersOrUpdateAndFillId.name, this.ordersRepository.saveBulkOrdersOrUpdateAndFillId(orders));

Check warning on line 483 in src/common/persistence/persistence.service.ts

View check run for this annotation

Codecov / codecov/patch

src/common/persistence/persistence.service.ts#L483

Added line #L483 was not covered by tests
}

async updateOrderWithStatus(order: OrderEntity, status: OrderStatusEnum) {
Expand Down Expand Up @@ -640,8 +651,11 @@ export class PersistenceService {
return await this.execute(this.insertAuction.name, this.auctionsRepository.insertAuction(auction));
}

async saveBulkAuctions(auctions: AuctionEntity[]): Promise<void> {
return await this.execute(this.saveBulkAuctions.name, this.auctionsRepository.saveBulkAuctions(auctions));
async saveBulkAuctionsOrUpdateAndFillId(auctions: AuctionEntity[]): Promise<void> {
return await this.execute(

Check warning on line 655 in src/common/persistence/persistence.service.ts

View check run for this annotation

Codecov / codecov/patch

src/common/persistence/persistence.service.ts#L655

Added line #L655 was not covered by tests
this.saveBulkAuctionsOrUpdateAndFillId.name,
this.auctionsRepository.saveBulkAuctionsOrUpdateAndFillId(auctions),
);
}

async rollbackAuctionAndOrdersByHash(blockHash: string): Promise<any> {
Expand Down Expand Up @@ -701,8 +715,8 @@ export class PersistenceService {
return await this.execute(this.saveOffer.name, this.offersRepository.saveOffer(offer));
}

async saveBulkOffers(offers: OfferEntity[]): Promise<void> {
return await this.execute(this.saveBulkOffers.name, this.offersRepository.saveBulkOffers(offers));
async saveBulkOffersOrUpdateAndFillId(offers: OfferEntity[]): Promise<void> {
return await this.execute(this.saveBulkOffersOrUpdateAndFillId.name, this.offersRepository.saveBulkOffersOrUpdateAndFillId(offers));

Check warning on line 719 in src/common/persistence/persistence.service.ts

View check run for this annotation

Codecov / codecov/patch

src/common/persistence/persistence.service.ts#L719

Added line #L719 was not covered by tests
}

async getOffersThatReachedDeadline(): Promise<OfferEntity[]> {
Expand Down
3 changes: 2 additions & 1 deletion src/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"defaultPageOffset": 0,
"defaultPageSize": 10,
"dbMaxDenominatedValue": 99999999999999999,
"dbMaxTagLength": 20
"dbMaxTagLength": 20,
"marketplaceReindexDataMaxInMemoryItems": 25000
},
"elasticDictionary": {
"scamInfo": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ export class MarketplacesReindexEventsSummaryService {
});
const tx = eventsSet[0].isTx ? eventsSet[0] : undefined;

const eventsStartIdx = tx ? 1 : 0;

const txData = tx?.data?.txData;

if (eventsOrderedByOrderAsc.length === 1 && tx) {
return [undefined, undefined];
return [undefined, txData];
}

const eventsStartIdx = tx ? 1 : 0;

return [eventsOrderedByOrderAsc.slice(eventsStartIdx), tx?.data?.txData];
return [eventsOrderedByOrderAsc.slice(eventsStartIdx), txData];
}

private getEventSummary(event: MarketplaceEventsEntity, txData: MarketplaceTransactionData, marketplace: Marketplace): any {
Expand Down
Loading

0 comments on commit 7bf7cf0

Please sign in to comment.