bulltrackers-module 1.0.246 → 1.0.247

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.
@@ -11,38 +11,43 @@ const { checkRootDataAvailability } = require('../data/AvailabilityChecker');
11
11
  const { FieldValue } = require('@google-cloud/firestore');
12
12
  const pLimit = require('p-limit');
13
13
  const path = require('path');
14
-
15
-
16
- // Attempt to load package.json to get version. Path depends on where this is invoked.
17
14
  const packageJson = require(path.join(__dirname, '..', '..', 'package.json'));
18
-
19
15
  const packageVersion = packageJson.version;
20
16
 
21
-
22
17
  /**
23
18
  * AUTO-RUN ENTRY POINT
24
19
  * Checks if a report for the current version exists. If not, runs it.
25
- * Designed to be called "Fire-and-Forget" at system init.
26
20
  */
27
21
  async function ensureBuildReport(config, dependencies, manifest) {
28
22
  const { db, logger } = dependencies;
29
23
  const now = new Date();
24
+
25
+ // BuildId still includes timestamp for uniqueness
30
26
  const buildId = `v${packageVersion}_${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}_${String(now.getHours()).padStart(2,'0')}-${String(now.getMinutes()).padStart(2,'0')}-${String(now.getSeconds()).padStart(2,'0')}`;
31
- const reportRef = db.collection('computation_build_records').doc(buildId);
27
+
28
+ // Reference to "latest" doc
29
+ const latestRef = db.collection('computation_build_records').doc('latest');
32
30
 
33
31
  try {
34
- const doc = await reportRef.get();
35
- if (doc.exists) {
36
- logger.log('INFO', `[BuildReporter] ✅ Pre-flight check for ${buildId} already exists. Skipping.`);
32
+ const latestDoc = await latestRef.get();
33
+ const priorVersion = latestDoc.exists ? latestDoc.data().packageVersion : null;
34
+
35
+ if (priorVersion === packageVersion) {
36
+ logger.log('INFO', `[BuildReporter] ✅ Version ${packageVersion} already has a report. Skipping.`);
37
37
  return;
38
38
  }
39
-
40
- logger.log('INFO', `[BuildReporter] 🚀 New Version Detected (${buildId}). Auto-running Pre-flight Report...`);
41
- // We do NOT await this in the main thread if called during init,
42
- // but here we are in an async function so we proceed.
43
- // Defaulting to 90 days for the auto-run to capture full historical impact
39
+
40
+ logger.log('INFO', `[BuildReporter] 🚀 New Version Detected (${packageVersion}). Auto-running Pre-flight Report...`);
41
+
44
42
  await generateBuildReport(config, dependencies, manifest, 90, buildId);
45
-
43
+
44
+ // Update "latest" pointer
45
+ await latestRef.set({
46
+ packageVersion,
47
+ buildId,
48
+ generatedAt: now.toISOString()
49
+ });
50
+
46
51
  } catch (e) {
47
52
  logger.log('ERROR', `[BuildReporter] Auto-run check failed: ${e.message}`);
48
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.246",
3
+ "version": "1.0.247",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [