@merkl/api 0.15.2 → 0.15.3

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.
@@ -1,4 +1,6 @@
1
1
  // ─── Reward Breakdowns ETL ───────────────────────────────────────────────────
2
+ process.env.ROOT = "0x44e39290a825dbfbe915f0a5c70c60753fbc7256a655a5e3c101de49f8557e88";
3
+ process.env.CHAIN_ID = "324";
2
4
  if (!process.env.ENV || !process.env.CHAIN_ID || !process.env.ROOT)
3
5
  throw new Error("[ENV]: missing variable");
4
6
  import { CampaignService } from "../../modules/v4/campaign";
@@ -22,7 +24,7 @@ const failedBatches = [];
22
24
  const extract = async () => {
23
25
  if (!file.exists())
24
26
  throw new Error("File does not exist.");
25
- const data = [];
27
+ let data = [];
26
28
  const textDecoder = new TextDecoder();
27
29
  let buffer = "";
28
30
  const stream = file.stream();
@@ -35,16 +37,27 @@ const extract = async () => {
35
37
  if (line.trim()) {
36
38
  data.push(...(await transform(JSON.parse(line))));
37
39
  }
40
+ if (data.length < 30_000)
41
+ continue;
38
42
  try {
39
43
  count += await withRetry(load, [data], 5, 60_000);
40
- data.length = 0;
44
+ data = [];
41
45
  }
42
46
  catch (err) {
43
47
  console.error(`Failed to insert a batch, adding it to the fail queue.\n${err}`);
44
- failedBatches.push([...data]);
45
- data.length = 0;
48
+ failedBatches.push(data);
49
+ data = [];
46
50
  }
47
51
  }
52
+ try {
53
+ count += await withRetry(load, [data], 5, 60_000);
54
+ data = [];
55
+ }
56
+ catch (err) {
57
+ console.error(`Failed to insert a batch, adding it to the fail queue.\n${err}`);
58
+ failedBatches.push(data);
59
+ data = [];
60
+ }
48
61
  return count;
49
62
  };
50
63
  // ─── Transform ───────────────────────────────────────────────────────────────