@merkl/api 0.10.403 → 0.10.405
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.
@@ -2,6 +2,7 @@
|
|
2
2
|
if (!process.env.ENV || !process.env.FILENAME)
|
3
3
|
throw new Error("[ENV]: missing variable");
|
4
4
|
import { RewardService } from "../../modules/v4/reward";
|
5
|
+
import { log } from "../../utils/logger";
|
5
6
|
import { S3Client } from "bun";
|
6
7
|
import moment from "moment";
|
7
8
|
// ─── Constants ───────────────────────────────────────────────
|
@@ -62,14 +63,14 @@ export const main = async () => {
|
|
62
63
|
const start = moment().unix();
|
63
64
|
// ─── Start Rewards ETL ───────────────────────────────────────────────
|
64
65
|
const count = await extract();
|
65
|
-
|
66
|
+
log.info(`✅ Successfully created ${count} new records for ${process.env.FILENAME} in ${moment().unix() - start} sec`);
|
66
67
|
if (failedBatches.length !== 0) {
|
67
|
-
|
68
|
+
log.error("pendings", `${failedBatches.length} batches failed.`);
|
68
69
|
process.exit(1);
|
69
70
|
}
|
70
71
|
if (failedBatches.length === 0) {
|
71
72
|
await file.delete();
|
72
|
-
|
73
|
+
log.info("Object deleted");
|
73
74
|
}
|
74
75
|
};
|
75
76
|
main();
|
@@ -1,6 +1,7 @@
|
|
1
1
|
// ─── Reward Breakdowns ETL ───────────────────────────────────────────────────
|
2
2
|
if (!process.env.ENV || !process.env.CHAIN_ID || !process.env.ROOT)
|
3
3
|
throw new Error("[ENV]: missing variable");
|
4
|
+
import { log } from "../../utils/logger";
|
4
5
|
import { apiDbClient } from "../../utils/prisma";
|
5
6
|
import { S3Client } from "bun";
|
6
7
|
import moment from "moment";
|
@@ -17,7 +18,7 @@ const failedBatches = [];
|
|
17
18
|
const extract = async () => {
|
18
19
|
if (!file.exists())
|
19
20
|
throw new Error("File does not exist.");
|
20
|
-
|
21
|
+
const data = [];
|
21
22
|
const textDecoder = new TextDecoder();
|
22
23
|
let buffer = "";
|
23
24
|
const stream = file.stream();
|
@@ -27,8 +28,9 @@ const extract = async () => {
|
|
27
28
|
const lines = buffer.split("\n");
|
28
29
|
buffer = lines.pop() || "";
|
29
30
|
for (const line of lines)
|
30
|
-
if (line.trim())
|
31
|
-
data
|
31
|
+
if (line.trim()) {
|
32
|
+
data.push(...transform(JSON.parse(line)));
|
33
|
+
}
|
32
34
|
try {
|
33
35
|
count += await load(data);
|
34
36
|
data.length = 0;
|
@@ -71,14 +73,14 @@ const load = async (rewardBreakdowns) => {
|
|
71
73
|
export const main = async () => {
|
72
74
|
const start = moment().unix();
|
73
75
|
const count = await extract();
|
74
|
-
|
76
|
+
log.info(`✅ Successfully created ${count} new records for ${process.env.CHAIN_ID}-${process.env.ROOT} in ${moment().unix() - start} sec`);
|
75
77
|
if (failedBatches.length !== 0) {
|
76
|
-
|
78
|
+
log.error("breakdowns", `${failedBatches.length} batches failed.`);
|
77
79
|
process.exit(1);
|
78
80
|
}
|
79
81
|
if (failedBatches.length === 0) {
|
80
|
-
await file.delete();
|
81
|
-
|
82
|
+
// await file.delete();
|
83
|
+
// log.info("Object deleted");
|
82
84
|
}
|
83
85
|
};
|
84
86
|
main();
|
@@ -1,6 +1,7 @@
|
|
1
1
|
// ─── Rewards ETL ─────────────────────────────────────────────────────────────
|
2
2
|
if (!process.env.ENV || !process.env.CHAIN_ID || !process.env.ROOT)
|
3
3
|
throw new Error("[ENV]: missing variable");
|
4
|
+
import { log } from "../../utils/logger";
|
4
5
|
import { apiDbClient } from "../../utils/prisma";
|
5
6
|
import { S3Client } from "bun";
|
6
7
|
import moment from "moment";
|
@@ -92,14 +93,14 @@ export const main = async () => {
|
|
92
93
|
});
|
93
94
|
// ─── Start Rewards ETL ───────────────────────────────────────────────
|
94
95
|
const count = await extract();
|
95
|
-
|
96
|
+
log.info(`✅ Successfully created ${count} new records for ${process.env.CHAIN_ID}-${process.env.ROOT} in ${moment().unix() - start} sec`);
|
96
97
|
if (failedBatches.length !== 0) {
|
97
|
-
|
98
|
+
log.error("rewards", `${failedBatches.length} batches failed.`);
|
98
99
|
process.exit(1);
|
99
100
|
}
|
100
101
|
if (failedBatches.length === 0) {
|
101
|
-
await file.delete();
|
102
|
-
|
102
|
+
// await file.delete();
|
103
|
+
// log.info("Object deleted");
|
103
104
|
}
|
104
105
|
};
|
105
106
|
main();
|