bulltrackers-module 1.0.424 → 1.0.425

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.
@@ -614,12 +614,15 @@ async function getUserPortfolio(req, res, dependencies, config) {
614
614
  }
615
615
 
616
616
  if (!portfolioData) {
617
- return res.status(404).json({ error: "Portfolio data not found for this user" });
617
+ return res.status(404).json({
618
+ error: "Portfolio data not found in any part document",
619
+ effectiveCid: effectiveCid,
620
+ isImpersonating: isImpersonating || false
621
+ });
618
622
  }
619
623
 
620
624
  // Apply dev override to AggregatedMirrors if dev override is active
621
- const { getDevOverride } = require('./dev_helpers');
622
- const devOverride = await getDevOverride(db, userCid, config, logger);
625
+ // Note: devOverride is already available from earlier in the function (line 573)
623
626
  if (devOverride && devOverride.enabled && devOverride.fakeCopiedPIs.length > 0 && portfolioData.AggregatedMirrors) {
624
627
  logger.log('INFO', `[getUserPortfolio] Applying DEV OVERRIDE to AggregatedMirrors for user ${userCid}`);
625
628
 
@@ -973,13 +976,17 @@ async function autoGenerateWatchlist(req, res, dependencies, config) {
973
976
  }
974
977
 
975
978
  try {
979
+ // Check for dev override impersonation (for computation lookup)
980
+ const { getEffectiveCid, getCopiedPIsWithDevOverride } = require('./dev_helpers');
981
+ const effectiveCid = await getEffectiveCid(db, userCid, config, logger);
982
+
976
983
  let copiedPIs = [];
977
984
  let dataSource = 'unknown';
978
985
  let isDevOverride = false;
979
986
  const today = new Date().toISOString().split('T')[0];
980
987
 
981
988
  // === DEV OVERRIDE CHECK (for developer accounts) ===
982
- const { getCopiedPIsWithDevOverride } = require('./dev_helpers');
989
+ // Note: Use actual userCid for dev override check (dev override is about what PIs the developer "copies")
983
990
  const devResult = await getCopiedPIsWithDevOverride(db, userCid, config, logger);
984
991
  if (devResult.isDevOverride) {
985
992
  copiedPIs = devResult.copiedPIs;
@@ -990,12 +997,14 @@ async function autoGenerateWatchlist(req, res, dependencies, config) {
990
997
 
991
998
  // === PRIMARY: Try to fetch from computation (cheaper/faster) ===
992
999
  // Only if dev override is not active
1000
+ // Use effectiveCid for computation lookup (to support impersonation)
993
1001
  if (!isDevOverride) {
994
1002
  const insightsCollection = config.unifiedInsightsCollection || 'unified_insights';
995
1003
  const category = 'signed_in_user';
996
1004
  const computationName = 'SignedInUserCopiedPIs';
997
1005
 
998
1006
  // Try to find latest computation date (with fallback)
1007
+ // Use effectiveCid for lookup (supports impersonation)
999
1008
  const resultsSub = config.resultsSubcollection || 'results';
1000
1009
  const compsSub = config.computationsSubcollection || 'computations';
1001
1010
  const computationDate = await findLatestComputationDate(
@@ -1005,7 +1014,7 @@ async function autoGenerateWatchlist(req, res, dependencies, config) {
1005
1014
  compsSub,
1006
1015
  category,
1007
1016
  computationName,
1008
- userCid,
1017
+ effectiveCid,
1009
1018
  30
1010
1019
  );
1011
1020
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.424",
3
+ "version": "1.0.425",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [