bulltrackers-module 1.0.217 → 1.0.218

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.
@@ -240,9 +240,34 @@ class HistoryExtractor {
240
240
  }
241
241
  }
242
242
 
243
+ /**
244
+ * FIXED: InsightsExtractor to properly handle document structure
245
+ * Document structure: { fetchedAt: Timestamp, insights: [...] }
246
+ */
247
+
243
248
  class InsightsExtractor {
244
- static getInsights(context) {
245
- return context.insights || context.daily_instrument_insights || [];
249
+ /**
250
+ * Gets insights array for today (default) or yesterday
251
+ * @param {Object} context - Computation context
252
+ * @param {string} timeframe - 'today' or 'yesterday'
253
+ * @returns {Array} Array of insight objects
254
+ */
255
+ static getInsights(context, timeframe = 'today') {
256
+ const insightsData = context.insights;
257
+
258
+ if (!insightsData) return [];
259
+
260
+ // Get the document for the requested timeframe
261
+ const doc = insightsData[timeframe]; // { fetchedAt: ..., insights: [...] }
262
+
263
+ if (!doc) return [];
264
+
265
+ // Extract the insights array from the document
266
+ if (doc.insights && Array.isArray(doc.insights)) {
267
+ return doc.insights;
268
+ }
269
+
270
+ return [];
246
271
  }
247
272
 
248
273
  static getInsightForInstrument(insights, instrumentId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.217",
3
+ "version": "1.0.218",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [