bulltrackers-module 1.0.706 → 1.0.709

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,7 +2,7 @@
2
2
  * @fileoverview Executor for "Standard" (User-Level) calculations.
3
3
  * REFACTORED: Hoisted data loading, centralized Series/Root logic.
4
4
  * UPDATED: Calls getResult() on computations to trigger summary logging.
5
- * FIXED: Force-increments shard indexes after every flush to prevent batch overwrites.
5
+ * FIXED: Removed redundant shard index increment that caused shard gaps (0, 2, 4...).
6
6
  */
7
7
  const { normalizeName, getEarliestDataDates } = require('../utils/utils');
8
8
  const { streamPortfolioData, streamHistoryData, getPortfolioPartRefs, getHistoryPartRefs } = require('../utils/data_loader');
@@ -279,7 +279,7 @@ class StandardExecutor {
279
279
  data = inst.results || {};
280
280
  }
281
281
 
282
- // Track active calculations to increment their shards later
282
+ // Track active calculations (for debugging/logging only now)
283
283
  if (Object.keys(data).length > 0) {
284
284
  activeCalcs.push(name);
285
285
  }
@@ -302,16 +302,10 @@ class StandardExecutor {
302
302
 
303
303
  const res = await commitResults(transformedState, dateStr, passName, config, deps, skipStatus, { flushMode: mode, shardIndexes: shardMap, isInitialWrite: isInitial });
304
304
 
305
- // Update shardMap from result
305
+ // Update shardMap from result.
306
+ // ResultCommitter now returns the CORRECT nextShardIndex (e.g. if it wrote shard_0, it returns 1).
306
307
  if (res.shardIndexes) Object.assign(shardMap, res.shardIndexes);
307
308
 
308
- // [FIX 2] Force increment shard indexes for active calculations.
309
- // This ensures the NEXT batch writes to a NEW shard (e.g. results_1)
310
- // instead of overwriting the current one (results_0).
311
- activeCalcs.forEach(name => {
312
- shardMap[name] = (shardMap[name] || 0) + 1;
313
- });
314
-
315
309
  return res;
316
310
  }
317
311
 
@@ -3,6 +3,7 @@
3
3
  * UPDATED: Added GCS Offloading logic (Hybrid Pointer System).
4
4
  * UPDATED: Preserved Legacy Sharding/Compression for backward compatibility.
5
5
  * UPDATED: Auto-cleanup of old Firestore shards when migrating a doc to GCS.
6
+ * FIXED: Disabled "Single Doc Compression" strategy during intermediate flushes to ensure consistent sharding.
6
7
  */
7
8
  const { commitBatchInChunks, generateDataHash, FieldValue } = require('../utils/utils');
8
9
  const { updateComputationStatus } = require('./StatusRepository');
@@ -366,7 +367,10 @@ async function writeSingleResult(result, docRef, name, dateContext, category, lo
366
367
  }
367
368
 
368
369
  // --- STRATEGY 2: FIRESTORE COMPRESSION ---
369
- if (totalSize > 50 * 1024) {
370
+ // FIX: Only compress if this is a single, atomic write (not part of a stream).
371
+ // Streaming relies on Strategy 3 (Sharding) to create distinct files (shard_0, shard_1...).
372
+ // If flushMode is INTERMEDIATE or we are already at a high shard index, we MUST fall through to sharding.
373
+ if (totalSize > 50 * 1024 && startShardIndex === 0 && flushMode !== 'INTERMEDIATE') {
370
374
  try {
371
375
  const compressedBuffer = zlib.gzipSync(rawBuffer);
372
376
  if (compressedBuffer.length < 900 * 1024) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.706",
3
+ "version": "1.0.709",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [