@tmlmobilidade/go-utils-exec 20260828.1831.23 → 20260829.51.31
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,14 +1,14 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type UnixMilliseconds } from '@tmlmobilidade/go-types-shared';
|
|
2
2
|
export interface PerformInTimeChunksItem {
|
|
3
|
-
end:
|
|
3
|
+
end: UnixMilliseconds;
|
|
4
4
|
index: number;
|
|
5
|
-
start:
|
|
5
|
+
start: UnixMilliseconds;
|
|
6
6
|
total: number;
|
|
7
7
|
}
|
|
8
8
|
export interface PerformInTimeChunksOptions {
|
|
9
|
-
endDate?:
|
|
9
|
+
endDate?: UnixMilliseconds;
|
|
10
10
|
intervalHrs: number;
|
|
11
11
|
onChunk: (chunk: PerformInTimeChunksItem) => Promise<void>;
|
|
12
|
-
startDate:
|
|
12
|
+
startDate: UnixMilliseconds;
|
|
13
13
|
}
|
|
14
14
|
export declare function performInTimeChunks({ endDate, intervalHrs, onChunk, startDate }: PerformInTimeChunksOptions): Promise<void>;
|
|
@@ -9,9 +9,9 @@ export async function performInTimeChunks({ endDate, intervalHrs, onChunk, start
|
|
|
9
9
|
// More recent data is more important than older data, so we start syncing the most recent data first.
|
|
10
10
|
// It makes sense to divide chunks by day, but this should be adjusted according to the volume of data in each chunk.
|
|
11
11
|
const endDateValue = endDate
|
|
12
|
-
? Dates.
|
|
13
|
-
: Dates.now('utc').minus({ seconds: 30 }).
|
|
14
|
-
const startDateValue = Dates.
|
|
12
|
+
? Dates.fromUnixMilliseconds(endDate).unix_milliseconds
|
|
13
|
+
: Dates.now('utc').minus({ seconds: 30 }).unix_milliseconds;
|
|
14
|
+
const startDateValue = Dates.fromUnixMilliseconds(startDate).unix_milliseconds;
|
|
15
15
|
const allTimestampChunks = splitTimeIntervals(startDateValue, endDateValue, intervalHrs);
|
|
16
16
|
//
|
|
17
17
|
// Iterate over each timestamp chunk and sync the documents.
|
|
@@ -21,12 +21,12 @@ export async function performInTimeChunks({ endDate, intervalHrs, onChunk, start
|
|
|
21
21
|
for (const [chunkIndex, chunkData] of allTimestampChunks.entries()) {
|
|
22
22
|
//
|
|
23
23
|
const chunkStartDate = Dates
|
|
24
|
-
.
|
|
24
|
+
.fromUnixMilliseconds(chunkData.start)
|
|
25
25
|
.setZone('Europe/Lisbon', 'offset_only');
|
|
26
26
|
const chunkEndDate = Dates
|
|
27
|
-
.
|
|
27
|
+
.fromUnixMilliseconds(chunkData.end)
|
|
28
28
|
.setZone('Europe/Lisbon', 'offset_only');
|
|
29
|
-
await onChunk({ end: chunkEndDate.
|
|
29
|
+
await onChunk({ end: chunkEndDate.unix_milliseconds, index: chunkIndex, start: chunkStartDate.unix_milliseconds, total: allTimestampChunks.length });
|
|
30
30
|
}
|
|
31
31
|
//
|
|
32
32
|
}
|