@merkl/api 0.10.308 → 0.10.310
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -249,30 +249,26 @@ export class RewardService {
|
|
249
249
|
BigInt(pending) -
|
250
250
|
BigInt(previousPending ?? "0")).toString();
|
251
251
|
};
|
252
|
-
let totalCreated = 0;
|
253
|
-
let totalUpdated = 0;
|
254
252
|
const breakdownUniques = await data.data.map(({ recipient, reason }) => {
|
255
253
|
const rewardId = RewardService.hashId(data.root, recipient, rewardTokenId);
|
256
254
|
return { rewardId, reason, campaignId };
|
257
255
|
});
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
256
|
+
const breakdownToUpdate = [];
|
257
|
+
const breakdownToCreate = [];
|
258
|
+
// for (let i = 0; i < breakdownUniques.length; i += 1_000) {
|
259
|
+
const exists = await RewardRepository.findManyBreakdownUniques(breakdownUniques);
|
260
|
+
console.log(exists);
|
261
|
+
for (const [pointIndex, point] of data.data.entries()) {
|
262
|
+
updateRewardUniques(point.recipient, point.pending, exists[pointIndex]?.pending);
|
263
|
+
console.log(pointIndex, !!exists[pointIndex]);
|
264
|
+
if (!!exists[pointIndex]) {
|
265
|
+
breakdownToUpdate.push(point);
|
266
|
+
}
|
267
|
+
else {
|
268
|
+
breakdownToCreate.push(point);
|
270
269
|
}
|
271
|
-
await RewardRepository.updateBreakdownPendings(rewardTokenId, data.root, campaignId, toUpdate);
|
272
|
-
await RewardRepository.createBreakdownPendings(rewardTokenId, data.root, campaignId, toCreate);
|
273
|
-
totalCreated += toCreate.length;
|
274
|
-
totalUpdated += toUpdate.length;
|
275
270
|
}
|
271
|
+
// }
|
276
272
|
try {
|
277
273
|
for (let i = 0; i < Object.keys(rewardUniques).length; i += 1_000) {
|
278
274
|
const toUpdate = [];
|
@@ -298,7 +294,9 @@ export class RewardService {
|
|
298
294
|
catch (e) {
|
299
295
|
log.error("updatePendings - error updating reward pendings", e);
|
300
296
|
}
|
301
|
-
|
297
|
+
await RewardRepository.updateBreakdownPendings(rewardTokenId, data.root, campaignId, breakdownToUpdate);
|
298
|
+
await RewardRepository.createBreakdownPendings(rewardTokenId, data.root, campaignId, breakdownToCreate);
|
299
|
+
return { created: breakdownToCreate.length, updated: breakdownToUpdate.length };
|
302
300
|
}
|
303
301
|
static async countAllchains() {
|
304
302
|
const rewardPerRewardTokenId = await RewardRepository.countRewardPerRewardTokenIdAndRoot();
|