@transcend-io/cli 6.26.7 → 6.26.8

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.
@@ -4,7 +4,7 @@
4
4
  * @param options - Options
5
5
  * @returns Number of items marked as completed
6
6
  */
7
- export declare function pushCronIdentifiersFromCsv({ file, dataSiloId, auth, sombraAuth, concurrency, transcendUrl, }: {
7
+ export declare function pushCronIdentifiersFromCsv({ file, dataSiloId, auth, sombraAuth, concurrency, transcendUrl, sleepSeconds, }: {
8
8
  /** CSV file path */
9
9
  file: string;
10
10
  /** Transcend API key authentication */
@@ -17,5 +17,7 @@ export declare function pushCronIdentifiersFromCsv({ file, dataSiloId, auth, som
17
17
  transcendUrl?: string;
18
18
  /** Sombra API key authentication */
19
19
  sombraAuth?: string;
20
+ /** Sleep time in seconds between chunks of concurrent calls */
21
+ sleepSeconds?: number;
20
22
  }): Promise<number>;
21
23
  //# sourceMappingURL=pushCronIdentifiersFromCsv.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pushCronIdentifiersFromCsv.d.ts","sourceRoot":"","sources":["../../src/cron/pushCronIdentifiersFromCsv.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,UAAU,EACV,WAAiB,EACjB,YAAoC,GACrC,EAAE;IACD,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CA8ElB"}
1
+ {"version":3,"file":"pushCronIdentifiersFromCsv.d.ts","sourceRoot":"","sources":["../../src/cron/pushCronIdentifiersFromCsv.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,UAAU,EACV,WAAiB,EACjB,YAAoC,EACpC,YAAiB,GAClB,EAAE;IACD,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,MAAM,CAAC,CA0GlB"}
@@ -12,13 +12,14 @@ const cli_progress_1 = __importDefault(require("cli-progress"));
12
12
  const logger_1 = require("../logger");
13
13
  const requests_1 = require("../requests");
14
14
  const constants_1 = require("../constants");
15
+ const chunk_1 = __importDefault(require("lodash/chunk"));
15
16
  /**
16
17
  * Given a CSV of cron job outputs, mark all requests as completed in Transcend
17
18
  *
18
19
  * @param options - Options
19
20
  * @returns Number of items marked as completed
20
21
  */
21
- async function pushCronIdentifiersFromCsv({ file, dataSiloId, auth, sombraAuth, concurrency = 100, transcendUrl = constants_1.DEFAULT_TRANSCEND_API, }) {
22
+ async function pushCronIdentifiersFromCsv({ file, dataSiloId, auth, sombraAuth, concurrency = 100, transcendUrl = constants_1.DEFAULT_TRANSCEND_API, sleepSeconds = 10, }) {
22
23
  // Create sombra instance to communicate with
23
24
  const sombra = await (0, graphql_1.createSombraGotInstance)(transcendUrl, auth, sombraAuth);
24
25
  // Read from CSV
@@ -34,22 +35,38 @@ async function pushCronIdentifiersFromCsv({ file, dataSiloId, auth, sombraAuth,
34
35
  let failureCount = 0;
35
36
  let errorCount = 0;
36
37
  progressBar.start(activeResults.length, 0);
37
- await (0, bluebird_1.map)(activeResults, async (identifier) => {
38
- try {
39
- const success = await (0, markCronIdentifierCompleted_1.markCronIdentifierCompleted)(sombra, identifier);
40
- if (success) {
41
- successCount += 1;
38
+ // Process in chunks with sleep intervals
39
+ const chunks = (0, chunk_1.default)(activeResults, concurrency);
40
+ const totalChunks = chunks.length;
41
+ const processChunk = async (items, chunkIndex) => {
42
+ logger_1.logger.info(colors_1.default.blue(`Processing chunk ${chunkIndex + 1}/${totalChunks} (${chunk_1.default.length} items)`));
43
+ // Process the items of the chunk concurrently
44
+ await (0, bluebird_1.map)(items, async (identifier) => {
45
+ try {
46
+ const success = await (0, markCronIdentifierCompleted_1.markCronIdentifierCompleted)(sombra, identifier);
47
+ if (success) {
48
+ successCount += 1;
49
+ }
50
+ else {
51
+ failureCount += 1;
52
+ }
42
53
  }
43
- else {
44
- failureCount += 1;
54
+ catch (e) {
55
+ logger_1.logger.error(colors_1.default.red(`Error notifying Transcend for identifier "${identifier.identifier}" - ${e === null || e === void 0 ? void 0 : e.message}`));
56
+ errorCount += 1;
45
57
  }
58
+ progressBar.update(successCount + failureCount);
59
+ });
60
+ // Sleep between chunks (except for the last chunk)
61
+ if (sleepSeconds > 0 && chunkIndex < totalChunks - 1) {
62
+ logger_1.logger.info(colors_1.default.yellow(`Sleeping for ${sleepSeconds}s before next chunk...`));
63
+ await new Promise((resolve) => {
64
+ setTimeout(resolve, sleepSeconds * 1000);
65
+ });
46
66
  }
47
- catch (e) {
48
- logger_1.logger.error(colors_1.default.red(`Error notifying Transcend for identifier "${identifier.identifier}" - ${e.message}`));
49
- errorCount += 1;
50
- }
51
- progressBar.update(successCount + failureCount);
52
- }, { concurrency });
67
+ };
68
+ // Process all chunks sequentially
69
+ await (0, bluebird_1.mapSeries)(chunks, processChunk);
53
70
  progressBar.stop();
54
71
  const t1 = new Date().getTime();
55
72
  const totalTime = t1 - t0;
@@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