@merkl/api 0.15.48 → 0.15.49
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.
@@ -148,7 +148,8 @@ const updatePendings = async (data) => {
|
|
148
148
|
}
|
149
149
|
}
|
150
150
|
const totalRewardIncrease = Object.values(rewardIdToPendingIncrease).reduce((prev, current) => prev + BigInt(current.pendingIncrease), 0n);
|
151
|
-
log.info(`
|
151
|
+
log.info(`total increase: ${totalRewardIncrease.toString()}, rewards to create: ${rewardToCreate.length}, to update: ${rewardToUpdate.length}`);
|
152
|
+
log.info(`total increase: ${totalBreakdownIncrease.toString()}, breakdowns to create: ${breakdownToCreate.length}, to update: ${breakdownToUpdate.length}`);
|
152
153
|
if (rewardToCreate.length > 0) {
|
153
154
|
const users = rewardToCreate.map(x => x.recipient);
|
154
155
|
await apiDbClient.user.createMany({ data: users.map(x => ({ address: x, tags: [] })), skipDuplicates: true });
|
@@ -168,20 +169,21 @@ const updatePendings = async (data) => {
|
|
168
169
|
}),
|
169
170
|
});
|
170
171
|
}
|
171
|
-
if (
|
172
|
-
await apiDbClient
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
172
|
+
if (breakdownToCreate.length > 0) {
|
173
|
+
await apiDbClient.rewardBreakdown.createMany({
|
174
|
+
data: breakdownToCreate.map(x => {
|
175
|
+
const rewardId = Bun.hash(`${root}${x.recipient}${rewardTokenId}`).toString();
|
176
|
+
return {
|
177
|
+
reason: x.reason,
|
178
|
+
amount: "0",
|
179
|
+
pending: x.pending,
|
180
|
+
claimed: "0",
|
181
|
+
rewardId,
|
182
|
+
campaignId,
|
183
|
+
};
|
184
|
+
}),
|
185
|
+
});
|
183
186
|
}
|
184
|
-
log.info(`breakdowns to create: ${breakdownToCreate.length}, to update: ${breakdownToUpdate.length}, total breakdown increase: ${totalBreakdownIncrease.toString()}`);
|
185
187
|
if (breakdownToUpdate.length > 0) {
|
186
188
|
await apiDbClient.$transaction(breakdownToUpdate.map(x => {
|
187
189
|
return apiDbClient.rewardBreakdown.update({
|
@@ -198,20 +200,18 @@ const updatePendings = async (data) => {
|
|
198
200
|
});
|
199
201
|
}));
|
200
202
|
}
|
201
|
-
if (
|
202
|
-
await apiDbClient.
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
}),
|
214
|
-
});
|
203
|
+
if (rewardToUpdate.length > 0) {
|
204
|
+
await apiDbClient.$transaction(rewardToUpdate.map(x => {
|
205
|
+
const rewardId = Bun.hash(`${data.root}${x.recipient}${rewardTokenId}`).toString();
|
206
|
+
return apiDbClient.reward.update({
|
207
|
+
where: {
|
208
|
+
id: rewardId,
|
209
|
+
},
|
210
|
+
data: {
|
211
|
+
pending: x.pending.toString(),
|
212
|
+
},
|
213
|
+
});
|
214
|
+
}));
|
215
215
|
}
|
216
216
|
return { created: breakdownToCreate.length, updated: breakdownToUpdate.length };
|
217
217
|
};
|