@merkl/api 0.10.312 → 0.10.314
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.
- package/dist/src/eden/index.d.ts +108 -9
- package/dist/src/index.d.ts +40 -9
- package/dist/src/modules/v4/router.d.ts +40 -9
- package/dist/src/modules/v4/status/status.controller.d.ts +40 -9
- package/dist/src/modules/v4/status/status.controller.js +17 -4
- package/dist/src/modules/v4/status/status.model.d.ts +6 -0
- package/dist/src/modules/v4/status/status.model.js +7 -0
- package/dist/src/modules/v4/status/status.repository.d.ts +19 -1
- package/dist/src/modules/v4/status/status.repository.js +25 -0
- package/dist/src/modules/v4/status/status.service.d.ts +21 -1
- package/dist/src/modules/v4/status/status.service.js +16 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -2183,6 +2183,40 @@ declare const eden: {
|
|
2183
2183
|
}[];
|
2184
2184
|
}>>;
|
2185
2185
|
};
|
2186
|
+
delay: {
|
2187
|
+
index: {
|
2188
|
+
get: (options: {
|
2189
|
+
headers?: Record<string, unknown> | undefined;
|
2190
|
+
query: {
|
2191
|
+
chainId?: number | undefined;
|
2192
|
+
endTimestampLowerBound?: number | undefined;
|
2193
|
+
delayLowerBound?: number | undefined;
|
2194
|
+
};
|
2195
|
+
fetch?: RequestInit | undefined;
|
2196
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
2197
|
+
200: {
|
2198
|
+
delay: number;
|
2199
|
+
delayFormatted: string;
|
2200
|
+
startTimestamp: bigint;
|
2201
|
+
endTimestamp: bigint;
|
2202
|
+
computeChainId: number;
|
2203
|
+
distributionChainId: number;
|
2204
|
+
campaignId: string;
|
2205
|
+
Opportunity: {
|
2206
|
+
name: string;
|
2207
|
+
};
|
2208
|
+
CampaignStatus: {
|
2209
|
+
error: string;
|
2210
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
2211
|
+
status: import("../../database/api/.generated").$Enums.RunStatus;
|
2212
|
+
campaignId: string;
|
2213
|
+
computedUntil: bigint;
|
2214
|
+
processingStarted: bigint;
|
2215
|
+
}[];
|
2216
|
+
}[];
|
2217
|
+
}>>;
|
2218
|
+
};
|
2219
|
+
};
|
2186
2220
|
};
|
2187
2221
|
liquidity: {
|
2188
2222
|
index: {
|
@@ -5554,9 +5588,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
5554
5588
|
};
|
5555
5589
|
};
|
5556
5590
|
};
|
5557
|
-
}
|
5558
|
-
} & {
|
5559
|
-
"campaign-status": {
|
5591
|
+
} & {
|
5560
5592
|
engine: {
|
5561
5593
|
overlaps: {
|
5562
5594
|
get: {
|
@@ -5575,9 +5607,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
5575
5607
|
};
|
5576
5608
|
};
|
5577
5609
|
};
|
5578
|
-
}
|
5579
|
-
} & {
|
5580
|
-
"campaign-status": {
|
5610
|
+
} & {
|
5581
5611
|
index: {
|
5582
5612
|
get: {
|
5583
5613
|
body: unknown;
|
@@ -5599,9 +5629,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
5599
5629
|
};
|
5600
5630
|
};
|
5601
5631
|
};
|
5602
|
-
}
|
5603
|
-
} & {
|
5604
|
-
"campaign-status": {
|
5632
|
+
} & {
|
5605
5633
|
":campaignId": {
|
5606
5634
|
get: {
|
5607
5635
|
body: unknown;
|
@@ -5629,6 +5657,43 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
5629
5657
|
};
|
5630
5658
|
};
|
5631
5659
|
};
|
5660
|
+
} & {
|
5661
|
+
delay: {
|
5662
|
+
index: {
|
5663
|
+
get: {
|
5664
|
+
body: unknown;
|
5665
|
+
params: {};
|
5666
|
+
query: {
|
5667
|
+
chainId?: number | undefined;
|
5668
|
+
endTimestampLowerBound?: number | undefined;
|
5669
|
+
delayLowerBound?: number | undefined;
|
5670
|
+
};
|
5671
|
+
headers: unknown;
|
5672
|
+
response: {
|
5673
|
+
200: {
|
5674
|
+
delay: number;
|
5675
|
+
delayFormatted: string;
|
5676
|
+
startTimestamp: bigint;
|
5677
|
+
endTimestamp: bigint;
|
5678
|
+
computeChainId: number;
|
5679
|
+
distributionChainId: number;
|
5680
|
+
campaignId: string;
|
5681
|
+
Opportunity: {
|
5682
|
+
name: string;
|
5683
|
+
};
|
5684
|
+
CampaignStatus: {
|
5685
|
+
error: string;
|
5686
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
5687
|
+
status: import("../../database/api/.generated").$Enums.RunStatus;
|
5688
|
+
campaignId: string;
|
5689
|
+
computedUntil: bigint;
|
5690
|
+
processingStarted: bigint;
|
5691
|
+
}[];
|
5692
|
+
}[];
|
5693
|
+
};
|
5694
|
+
};
|
5695
|
+
};
|
5696
|
+
};
|
5632
5697
|
};
|
5633
5698
|
};
|
5634
5699
|
} & {
|
@@ -8764,6 +8829,40 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
8764
8829
|
}[];
|
8765
8830
|
}>>;
|
8766
8831
|
};
|
8832
|
+
delay: {
|
8833
|
+
index: {
|
8834
|
+
get: (options: {
|
8835
|
+
headers?: Record<string, unknown> | undefined;
|
8836
|
+
query: {
|
8837
|
+
chainId?: number | undefined;
|
8838
|
+
endTimestampLowerBound?: number | undefined;
|
8839
|
+
delayLowerBound?: number | undefined;
|
8840
|
+
};
|
8841
|
+
fetch?: RequestInit | undefined;
|
8842
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
8843
|
+
200: {
|
8844
|
+
delay: number;
|
8845
|
+
delayFormatted: string;
|
8846
|
+
startTimestamp: bigint;
|
8847
|
+
endTimestamp: bigint;
|
8848
|
+
computeChainId: number;
|
8849
|
+
distributionChainId: number;
|
8850
|
+
campaignId: string;
|
8851
|
+
Opportunity: {
|
8852
|
+
name: string;
|
8853
|
+
};
|
8854
|
+
CampaignStatus: {
|
8855
|
+
error: string;
|
8856
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
8857
|
+
status: import("../../database/api/.generated").$Enums.RunStatus;
|
8858
|
+
campaignId: string;
|
8859
|
+
computedUntil: bigint;
|
8860
|
+
processingStarted: bigint;
|
8861
|
+
}[];
|
8862
|
+
}[];
|
8863
|
+
}>>;
|
8864
|
+
};
|
8865
|
+
};
|
8767
8866
|
};
|
8768
8867
|
liquidity: {
|
8769
8868
|
index: {
|
package/dist/src/index.d.ts
CHANGED
@@ -2639,9 +2639,7 @@ declare const app: Elysia<"", false, {
|
|
2639
2639
|
};
|
2640
2640
|
};
|
2641
2641
|
};
|
2642
|
-
}
|
2643
|
-
} & {
|
2644
|
-
"campaign-status": {
|
2642
|
+
} & {
|
2645
2643
|
engine: {
|
2646
2644
|
overlaps: {
|
2647
2645
|
get: {
|
@@ -2660,9 +2658,7 @@ declare const app: Elysia<"", false, {
|
|
2660
2658
|
};
|
2661
2659
|
};
|
2662
2660
|
};
|
2663
|
-
}
|
2664
|
-
} & {
|
2665
|
-
"campaign-status": {
|
2661
|
+
} & {
|
2666
2662
|
index: {
|
2667
2663
|
get: {
|
2668
2664
|
body: unknown;
|
@@ -2684,9 +2680,7 @@ declare const app: Elysia<"", false, {
|
|
2684
2680
|
};
|
2685
2681
|
};
|
2686
2682
|
};
|
2687
|
-
}
|
2688
|
-
} & {
|
2689
|
-
"campaign-status": {
|
2683
|
+
} & {
|
2690
2684
|
":campaignId": {
|
2691
2685
|
get: {
|
2692
2686
|
body: unknown;
|
@@ -2714,6 +2708,43 @@ declare const app: Elysia<"", false, {
|
|
2714
2708
|
};
|
2715
2709
|
};
|
2716
2710
|
};
|
2711
|
+
} & {
|
2712
|
+
delay: {
|
2713
|
+
index: {
|
2714
|
+
get: {
|
2715
|
+
body: unknown;
|
2716
|
+
params: {};
|
2717
|
+
query: {
|
2718
|
+
chainId?: number | undefined;
|
2719
|
+
endTimestampLowerBound?: number | undefined;
|
2720
|
+
delayLowerBound?: number | undefined;
|
2721
|
+
};
|
2722
|
+
headers: unknown;
|
2723
|
+
response: {
|
2724
|
+
200: {
|
2725
|
+
delay: number;
|
2726
|
+
delayFormatted: string;
|
2727
|
+
startTimestamp: bigint;
|
2728
|
+
endTimestamp: bigint;
|
2729
|
+
computeChainId: number;
|
2730
|
+
distributionChainId: number;
|
2731
|
+
campaignId: string;
|
2732
|
+
Opportunity: {
|
2733
|
+
name: string;
|
2734
|
+
};
|
2735
|
+
CampaignStatus: {
|
2736
|
+
error: string;
|
2737
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
2738
|
+
status: import("../database/api/.generated").$Enums.RunStatus;
|
2739
|
+
campaignId: string;
|
2740
|
+
computedUntil: bigint;
|
2741
|
+
processingStarted: bigint;
|
2742
|
+
}[];
|
2743
|
+
}[];
|
2744
|
+
};
|
2745
|
+
};
|
2746
|
+
};
|
2747
|
+
};
|
2717
2748
|
};
|
2718
2749
|
};
|
2719
2750
|
} & {
|
@@ -2517,9 +2517,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
2517
2517
|
};
|
2518
2518
|
};
|
2519
2519
|
};
|
2520
|
-
}
|
2521
|
-
} & {
|
2522
|
-
"campaign-status": {
|
2520
|
+
} & {
|
2523
2521
|
engine: {
|
2524
2522
|
overlaps: {
|
2525
2523
|
get: {
|
@@ -2538,9 +2536,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
2538
2536
|
};
|
2539
2537
|
};
|
2540
2538
|
};
|
2541
|
-
}
|
2542
|
-
} & {
|
2543
|
-
"campaign-status": {
|
2539
|
+
} & {
|
2544
2540
|
index: {
|
2545
2541
|
get: {
|
2546
2542
|
body: unknown;
|
@@ -2562,9 +2558,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
2562
2558
|
};
|
2563
2559
|
};
|
2564
2560
|
};
|
2565
|
-
}
|
2566
|
-
} & {
|
2567
|
-
"campaign-status": {
|
2561
|
+
} & {
|
2568
2562
|
":campaignId": {
|
2569
2563
|
get: {
|
2570
2564
|
body: unknown;
|
@@ -2592,6 +2586,43 @@ export declare const v4: Elysia<"/v4", false, {
|
|
2592
2586
|
};
|
2593
2587
|
};
|
2594
2588
|
};
|
2589
|
+
} & {
|
2590
|
+
delay: {
|
2591
|
+
index: {
|
2592
|
+
get: {
|
2593
|
+
body: unknown;
|
2594
|
+
params: {};
|
2595
|
+
query: {
|
2596
|
+
chainId?: number | undefined;
|
2597
|
+
endTimestampLowerBound?: number | undefined;
|
2598
|
+
delayLowerBound?: number | undefined;
|
2599
|
+
};
|
2600
|
+
headers: unknown;
|
2601
|
+
response: {
|
2602
|
+
200: {
|
2603
|
+
delay: number;
|
2604
|
+
delayFormatted: string;
|
2605
|
+
startTimestamp: bigint;
|
2606
|
+
endTimestamp: bigint;
|
2607
|
+
computeChainId: number;
|
2608
|
+
distributionChainId: number;
|
2609
|
+
campaignId: string;
|
2610
|
+
Opportunity: {
|
2611
|
+
name: string;
|
2612
|
+
};
|
2613
|
+
CampaignStatus: {
|
2614
|
+
error: string;
|
2615
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
2616
|
+
status: import("../../../database/api/.generated").$Enums.RunStatus;
|
2617
|
+
campaignId: string;
|
2618
|
+
computedUntil: bigint;
|
2619
|
+
processingStarted: bigint;
|
2620
|
+
}[];
|
2621
|
+
}[];
|
2622
|
+
};
|
2623
|
+
};
|
2624
|
+
};
|
2625
|
+
};
|
2595
2626
|
};
|
2596
2627
|
};
|
2597
2628
|
} & {
|
@@ -43,9 +43,7 @@ export declare const StatusController: Elysia<"/campaign-status", false, {
|
|
43
43
|
};
|
44
44
|
};
|
45
45
|
};
|
46
|
-
}
|
47
|
-
} & {
|
48
|
-
"campaign-status": {
|
46
|
+
} & {
|
49
47
|
engine: {
|
50
48
|
overlaps: {
|
51
49
|
get: {
|
@@ -64,9 +62,7 @@ export declare const StatusController: Elysia<"/campaign-status", false, {
|
|
64
62
|
};
|
65
63
|
};
|
66
64
|
};
|
67
|
-
}
|
68
|
-
} & {
|
69
|
-
"campaign-status": {
|
65
|
+
} & {
|
70
66
|
index: {
|
71
67
|
get: {
|
72
68
|
body: unknown;
|
@@ -88,9 +84,7 @@ export declare const StatusController: Elysia<"/campaign-status", false, {
|
|
88
84
|
};
|
89
85
|
};
|
90
86
|
};
|
91
|
-
}
|
92
|
-
} & {
|
93
|
-
"campaign-status": {
|
87
|
+
} & {
|
94
88
|
":campaignId": {
|
95
89
|
get: {
|
96
90
|
body: unknown;
|
@@ -118,6 +112,43 @@ export declare const StatusController: Elysia<"/campaign-status", false, {
|
|
118
112
|
};
|
119
113
|
};
|
120
114
|
};
|
115
|
+
} & {
|
116
|
+
delay: {
|
117
|
+
index: {
|
118
|
+
get: {
|
119
|
+
body: unknown;
|
120
|
+
params: {};
|
121
|
+
query: {
|
122
|
+
chainId?: number | undefined;
|
123
|
+
endTimestampLowerBound?: number | undefined;
|
124
|
+
delayLowerBound?: number | undefined;
|
125
|
+
};
|
126
|
+
headers: unknown;
|
127
|
+
response: {
|
128
|
+
200: {
|
129
|
+
delay: number;
|
130
|
+
delayFormatted: string;
|
131
|
+
startTimestamp: bigint;
|
132
|
+
endTimestamp: bigint;
|
133
|
+
computeChainId: number;
|
134
|
+
distributionChainId: number;
|
135
|
+
campaignId: string;
|
136
|
+
Opportunity: {
|
137
|
+
name: string;
|
138
|
+
};
|
139
|
+
CampaignStatus: {
|
140
|
+
error: string;
|
141
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
142
|
+
status: import("../../../../database/api/.generated").$Enums.RunStatus;
|
143
|
+
campaignId: string;
|
144
|
+
computedUntil: bigint;
|
145
|
+
processingStarted: bigint;
|
146
|
+
}[];
|
147
|
+
}[];
|
148
|
+
};
|
149
|
+
};
|
150
|
+
};
|
151
|
+
};
|
121
152
|
};
|
122
153
|
}, {
|
123
154
|
derive: {};
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.guard";
|
2
|
+
import { throwOnUnsupportedChainId } from "../../../utils/throw";
|
2
3
|
import Elysia from "elysia";
|
3
|
-
import { CampaignUniqueDto, QueryCampaignStatusDto, UpdateCampaignStatusDto } from "./status.model";
|
4
|
+
import { CampaignUniqueDto, DelayDto, QueryCampaignStatusDto, UpdateCampaignStatusDto } from "./status.model";
|
4
5
|
import { StatusService } from "./status.service";
|
5
6
|
export const StatusController = new Elysia({ prefix: "/campaign-status", detail: { tags: ["Status"], hide: true } })
|
6
7
|
// ─── Update a Campaign Status ──────────────────────────────────────
|
@@ -12,15 +13,15 @@ export const StatusController = new Elysia({ prefix: "/campaign-status", detail:
|
|
12
13
|
headers: AuthorizationHeadersDto,
|
13
14
|
body: UpdateCampaignStatusDto,
|
14
15
|
})
|
15
|
-
// ─── Is Safe For Overlaps
|
16
|
+
// ─── Is Safe For Overlaps ───────────────────────────────────────────
|
16
17
|
.get("/engine/overlaps", async ({ query }) => await StatusService.isSafeForOverlaps(query), {
|
17
18
|
beforeHandle: EngineGuard,
|
18
19
|
headers: AuthorizationHeadersDto,
|
19
20
|
query: CampaignUniqueDto,
|
20
21
|
})
|
21
|
-
// ─── Find Many Status
|
22
|
+
// ─── Find Many Status ─────────────────────────────────────────────────
|
22
23
|
.get("/", async ({ query }) => await StatusService.findMany(query), { query: QueryCampaignStatusDto })
|
23
|
-
// ─── Get A Status By Id
|
24
|
+
// ─── Get A Status By Id ───────────────────────────────────────────────
|
24
25
|
// campaignId will be either a rough campaignId in the engine sense, a campaignId in the api db way, or a distributionChain_campaignId
|
25
26
|
.get("/:campaignId", async ({ params }) => {
|
26
27
|
if (!params.campaignId.includes("-") && params.campaignId.startsWith("0x"))
|
@@ -29,4 +30,16 @@ export const StatusController = new Elysia({ prefix: "/campaign-status", detail:
|
|
29
30
|
return await StatusService.findUniqueOrThrow(params.campaignId);
|
30
31
|
const [distributionChain, campaignId] = params.campaignId.split("-");
|
31
32
|
return await StatusService.findUniqueOrThrow({ distributionChain: +distributionChain, campaignId });
|
33
|
+
})
|
34
|
+
// ─── Fetch information about delays ────────────────────────────────────
|
35
|
+
.group("/delay", app => {
|
36
|
+
return app.get("/", async ({ query }) => StatusService.findManyDelay(query), {
|
37
|
+
query: DelayDto,
|
38
|
+
beforeHandle: ({ query }) => {
|
39
|
+
if (!!query.chainId) {
|
40
|
+
throwOnUnsupportedChainId(query.chainId);
|
41
|
+
}
|
42
|
+
},
|
43
|
+
detail: { hide: true },
|
44
|
+
});
|
32
45
|
});
|
@@ -8,6 +8,11 @@ export declare const CampaignUniqueDto: import("@sinclair/typebox").TObject<{
|
|
8
8
|
distributionChain: import("@sinclair/typebox").TNumber;
|
9
9
|
campaignId: import("@sinclair/typebox").TString;
|
10
10
|
}>;
|
11
|
+
export declare const DelayDto: import("@sinclair/typebox").TObject<{
|
12
|
+
endTimestampLowerBound: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
13
|
+
delayLowerBound: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
14
|
+
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
15
|
+
}>;
|
11
16
|
export declare const CampaignStatusResourceDto: import("@sinclair/typebox").TObject<{
|
12
17
|
campaignId: import("@sinclair/typebox").TString;
|
13
18
|
computedUntil: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TBigInt, import("@sinclair/typebox").TString]>;
|
@@ -44,5 +49,6 @@ export declare const QueryCampaignStatusDto: import("@sinclair/typebox").TObject
|
|
44
49
|
SKIPPED: "SKIPPED";
|
45
50
|
}>]>>;
|
46
51
|
}>;
|
52
|
+
export type DelayModel = typeof DelayDto.static;
|
47
53
|
export type UpdateStatusModel = typeof UpdateCampaignStatusDto.static;
|
48
54
|
export type QueryCampaignStatus = typeof QueryCampaignStatusDto.static;
|
@@ -5,6 +5,13 @@ export const CampaignUniqueDto = t.Object({
|
|
5
5
|
distributionChain: t.Numeric(),
|
6
6
|
campaignId: t.String(),
|
7
7
|
});
|
8
|
+
export const DelayDto = t.Object({
|
9
|
+
endTimestampLowerBound: t.Optional(t.Numeric({
|
10
|
+
description: "Lower bound of end timestamps - by default it'll take all campaigns where endTimestamp is more than now - 1 week",
|
11
|
+
})),
|
12
|
+
delayLowerBound: t.Optional(t.Numeric({ description: "To filter small delays (in seconds)" })),
|
13
|
+
chainId: t.Optional(t.Numeric({ description: "To get delays for Campaigns on a given chain only" })),
|
14
|
+
});
|
8
15
|
export const CampaignStatusResourceDto = t.Object({
|
9
16
|
campaignId: t.String(),
|
10
17
|
computedUntil: t.Union([t.BigInt(), t.String()]),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { Prisma, RunStatus } from "../../../../database/api/.generated";
|
2
2
|
import { type CampaignUnique } from "../campaign";
|
3
|
-
import type { QueryCampaignStatus } from "./status.model";
|
3
|
+
import type { DelayModel, QueryCampaignStatus } from "./status.model";
|
4
4
|
export declare class StatusRepository {
|
5
5
|
#private;
|
6
6
|
static findMany(query: QueryCampaignStatus): Promise<{
|
@@ -67,4 +67,22 @@ export declare class StatusRepository {
|
|
67
67
|
computedUntil: bigint;
|
68
68
|
processingStarted: bigint;
|
69
69
|
}>;
|
70
|
+
static findManyDelay(query: DelayModel): Promise<{
|
71
|
+
startTimestamp: bigint;
|
72
|
+
endTimestamp: bigint;
|
73
|
+
computeChainId: number;
|
74
|
+
distributionChainId: number;
|
75
|
+
campaignId: string;
|
76
|
+
Opportunity: {
|
77
|
+
name: string;
|
78
|
+
};
|
79
|
+
CampaignStatus: {
|
80
|
+
error: string;
|
81
|
+
details: Prisma.JsonValue;
|
82
|
+
status: import("../../../../database/api/.generated").$Enums.RunStatus;
|
83
|
+
campaignId: string;
|
84
|
+
computedUntil: bigint;
|
85
|
+
processingStarted: bigint;
|
86
|
+
}[];
|
87
|
+
}[]>;
|
70
88
|
}
|
@@ -79,4 +79,29 @@ export class StatusRepository {
|
|
79
79
|
},
|
80
80
|
});
|
81
81
|
}
|
82
|
+
static async findManyDelay(query) {
|
83
|
+
return await apiDbClient.campaign.findMany({
|
84
|
+
where: {
|
85
|
+
distributionChainId: !!query.chainId ? query.chainId : undefined,
|
86
|
+
endTimestamp: {
|
87
|
+
gte: !!query.endTimestampLowerBound ? query.endTimestampLowerBound : moment().subtract(1, "week").unix(),
|
88
|
+
},
|
89
|
+
},
|
90
|
+
select: {
|
91
|
+
campaignId: true,
|
92
|
+
computeChainId: true,
|
93
|
+
startTimestamp: true,
|
94
|
+
endTimestamp: true,
|
95
|
+
distributionChainId: true,
|
96
|
+
Opportunity: {
|
97
|
+
select: {
|
98
|
+
name: true,
|
99
|
+
},
|
100
|
+
},
|
101
|
+
CampaignStatus: {
|
102
|
+
take: 1,
|
103
|
+
},
|
104
|
+
},
|
105
|
+
});
|
106
|
+
}
|
82
107
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { type CampaignUnique } from "../campaign";
|
2
|
-
import type { QueryCampaignStatus, UpdateStatusModel } from "./status.model";
|
2
|
+
import type { DelayModel, QueryCampaignStatus, UpdateStatusModel } from "./status.model";
|
3
3
|
export declare class StatusService {
|
4
4
|
static findMany(query: QueryCampaignStatus): Promise<{
|
5
5
|
error: string;
|
@@ -35,4 +35,24 @@ export declare class StatusService {
|
|
35
35
|
} | null>;
|
36
36
|
static update(campaignUnique: CampaignUnique, status: UpdateStatusModel): Promise<void>;
|
37
37
|
static isSafeForOverlaps(campaignUnique: CampaignUnique): Promise<boolean>;
|
38
|
+
static findManyDelay(query: DelayModel): Promise<{
|
39
|
+
delay: number;
|
40
|
+
delayFormatted: string;
|
41
|
+
startTimestamp: bigint;
|
42
|
+
endTimestamp: bigint;
|
43
|
+
computeChainId: number;
|
44
|
+
distributionChainId: number;
|
45
|
+
campaignId: string;
|
46
|
+
Opportunity: {
|
47
|
+
name: string;
|
48
|
+
};
|
49
|
+
CampaignStatus: {
|
50
|
+
error: string;
|
51
|
+
details: import("database/api/.generated/runtime/library").JsonValue;
|
52
|
+
status: import("../../../../database/api/.generated").$Enums.RunStatus;
|
53
|
+
campaignId: string;
|
54
|
+
computedUntil: bigint;
|
55
|
+
processingStarted: bigint;
|
56
|
+
}[];
|
57
|
+
}[]>;
|
38
58
|
}
|
@@ -54,4 +54,20 @@ export class StatusService {
|
|
54
54
|
}
|
55
55
|
return true;
|
56
56
|
}
|
57
|
+
static async findManyDelay(query) {
|
58
|
+
const now = moment().unix();
|
59
|
+
return (await StatusRepository.findManyDelay(query))
|
60
|
+
.map(x => {
|
61
|
+
const endTimestamp = Number.parseInt(x.endTimestamp.toString());
|
62
|
+
const delay = Math.min(now, endTimestamp) -
|
63
|
+
Math.min(now, endTimestamp, Number.parseInt((x.CampaignStatus?.[0]?.computedUntil ?? x.startTimestamp).toString()));
|
64
|
+
return {
|
65
|
+
...x,
|
66
|
+
delay: delay,
|
67
|
+
delayFormatted: moment.duration(delay, "seconds").humanize(),
|
68
|
+
};
|
69
|
+
})
|
70
|
+
.sort((a, b) => b.delay - a.delay)
|
71
|
+
.filter(x => x.delay > (query.delayLowerBound ?? 0));
|
72
|
+
}
|
57
73
|
}
|