@merkl/api 0.16.24 → 0.16.25
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.
@@ -8,6 +8,8 @@ import { TokenService } from "../token/token.service";
|
|
8
8
|
import { InvalidParameter } from "../../../utils/error";
|
9
9
|
import { executeSimple } from "../../../utils/execute";
|
10
10
|
import { log } from "../../../utils/logger";
|
11
|
+
import { apiDbClient } from "../../../utils/prisma";
|
12
|
+
import { RunStatus } from "../../../../database/api/.generated";
|
11
13
|
import { Campaign as CampaignEnum, NETWORK_LABELS, } from "@sdk";
|
12
14
|
import { utils } from "ethers";
|
13
15
|
import moment from "moment";
|
@@ -155,9 +157,20 @@ export class CampaignService {
|
|
155
157
|
return await CampaignRepository.findUniqueOrThrow(id);
|
156
158
|
}
|
157
159
|
static async findCampaignsToProcess(distributionChainId) {
|
160
|
+
await apiDbClient.campaignStatus.updateMany({
|
161
|
+
data: {
|
162
|
+
status: RunStatus.FAILED,
|
163
|
+
},
|
164
|
+
where: {
|
165
|
+
Campaign: {
|
166
|
+
distributionChainId: 1,
|
167
|
+
},
|
168
|
+
status: RunStatus.PROCESSING,
|
169
|
+
},
|
170
|
+
});
|
158
171
|
return (await CampaignRepository.findCampaignsToProcess(distributionChainId))
|
159
|
-
.filter(campaign => campaign.endTimestamp > (campaign?.CampaignStatus?.[0]?.computedUntil ??
|
160
|
-
?.sort((a, b) => Number((a.CampaignStatus?.[0]?.processingStarted ??
|
172
|
+
.filter(campaign => campaign.endTimestamp > (campaign?.CampaignStatus?.[0]?.computedUntil ?? 0n))
|
173
|
+
?.sort((a, b) => Number((a.CampaignStatus?.[0]?.processingStarted ?? 0n) - (b.CampaignStatus?.[0]?.processingStarted ?? 0n)));
|
161
174
|
}
|
162
175
|
static async findNextCampaignToProcess(chainId) {
|
163
176
|
const campaigns = await CampaignService.findCampaignsToProcess(chainId);
|