bulltrackers-module 1.0.421 → 1.0.422
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.
|
@@ -546,12 +546,30 @@ async function getUserPortfolio(req, res, dependencies, config) {
|
|
|
546
546
|
return res.status(404).json({ error: "Portfolio data not found for this user" });
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
+
// Apply dev override to AggregatedMirrors if dev override is active
|
|
550
|
+
const { getDevOverride } = require('./dev_helpers');
|
|
551
|
+
const devOverride = await getDevOverride(db, userCid, config, logger);
|
|
552
|
+
if (devOverride && devOverride.enabled && devOverride.fakeCopiedPIs.length > 0 && portfolioData.AggregatedMirrors) {
|
|
553
|
+
logger.log('INFO', `[getUserPortfolio] Applying DEV OVERRIDE to AggregatedMirrors for user ${userCid}`);
|
|
554
|
+
|
|
555
|
+
// Replace AggregatedMirrors with fake ones from dev override
|
|
556
|
+
portfolioData.AggregatedMirrors = devOverride.fakeCopiedPIs.map(cid => ({
|
|
557
|
+
ParentCID: Number(cid),
|
|
558
|
+
ParentUsername: `PI-${cid}`, // Placeholder, will be resolved if needed
|
|
559
|
+
Invested: 0,
|
|
560
|
+
NetProfit: 0,
|
|
561
|
+
Value: 0,
|
|
562
|
+
PendingForClosure: false
|
|
563
|
+
}));
|
|
564
|
+
}
|
|
565
|
+
|
|
549
566
|
return res.status(200).json({
|
|
550
567
|
portfolio: portfolioData,
|
|
551
568
|
date: dataDate,
|
|
552
569
|
isFallback: isFallback,
|
|
553
570
|
requestedDate: today,
|
|
554
|
-
userCid: String(userCid)
|
|
571
|
+
userCid: String(userCid),
|
|
572
|
+
devOverrideActive: devOverride && devOverride.enabled
|
|
555
573
|
});
|
|
556
574
|
|
|
557
575
|
} catch (error) {
|
|
@@ -710,6 +728,11 @@ async function getUserComputations(req, res, dependencies, config) {
|
|
|
710
728
|
return res.status(400).json({ error: "Please specify at least one computation name" });
|
|
711
729
|
}
|
|
712
730
|
|
|
731
|
+
// Check for dev override (for developer accounts)
|
|
732
|
+
const { getDevOverride } = require('./dev_helpers');
|
|
733
|
+
const devOverride = await getDevOverride(db, userCid, config, logger);
|
|
734
|
+
const isDevOverrideActive = devOverride && devOverride.enabled && devOverride.fakeCopiedPIs.length > 0;
|
|
735
|
+
|
|
713
736
|
let datesToCheck = [today];
|
|
714
737
|
|
|
715
738
|
// If mode is 'latest', try to find the latest available date for the first computation
|
|
@@ -777,7 +800,42 @@ async function getUserComputations(req, res, dependencies, config) {
|
|
|
777
800
|
const rawData = doc.data();
|
|
778
801
|
const data = tryDecompress(rawData);
|
|
779
802
|
// Filter by user CID - computation results are stored as { cid: result }
|
|
780
|
-
|
|
803
|
+
let userResult = data[String(userCid)];
|
|
804
|
+
|
|
805
|
+
// Apply dev override for computations that include copied PIs
|
|
806
|
+
if (isDevOverrideActive && (compName === 'SignedInUserProfileMetrics' || compName === 'SignedInUserCopiedPIs')) {
|
|
807
|
+
if (compName === 'SignedInUserCopiedPIs') {
|
|
808
|
+
// Override the copied PIs list
|
|
809
|
+
userResult = {
|
|
810
|
+
current: devOverride.fakeCopiedPIs,
|
|
811
|
+
past: [],
|
|
812
|
+
all: devOverride.fakeCopiedPIs
|
|
813
|
+
};
|
|
814
|
+
logger.log('INFO', `[getUserComputations] Applied DEV OVERRIDE to SignedInUserCopiedPIs for user ${userCid}`);
|
|
815
|
+
} else if (compName === 'SignedInUserProfileMetrics' && userResult && userResult.copiedPIs) {
|
|
816
|
+
// Override the copiedPIs data in SignedInUserProfileMetrics
|
|
817
|
+
// We need to construct fake mirror data from the dev override PIs
|
|
818
|
+
const fakeMirrors = devOverride.fakeCopiedPIs.map(cid => ({
|
|
819
|
+
cid: Number(cid),
|
|
820
|
+
username: `PI-${cid}`, // Placeholder, will be resolved from rankings if available
|
|
821
|
+
invested: 0,
|
|
822
|
+
netProfit: 0,
|
|
823
|
+
value: 0,
|
|
824
|
+
pendingClosure: false,
|
|
825
|
+
isRanked: false
|
|
826
|
+
}));
|
|
827
|
+
|
|
828
|
+
userResult = {
|
|
829
|
+
...userResult,
|
|
830
|
+
copiedPIs: {
|
|
831
|
+
chartType: 'cards',
|
|
832
|
+
data: fakeMirrors
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
logger.log('INFO', `[getUserComputations] Applied DEV OVERRIDE to SignedInUserProfileMetrics.copiedPIs for user ${userCid}`);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
781
839
|
if (userResult) {
|
|
782
840
|
results[date][compName] = userResult;
|
|
783
841
|
}
|
|
@@ -809,7 +867,8 @@ async function getUserComputations(req, res, dependencies, config) {
|
|
|
809
867
|
computations: computationNames,
|
|
810
868
|
data: cleanedResults,
|
|
811
869
|
isFallback: isFallback,
|
|
812
|
-
requestedDate: today
|
|
870
|
+
requestedDate: today,
|
|
871
|
+
devOverrideActive: isDevOverrideActive
|
|
813
872
|
});
|
|
814
873
|
|
|
815
874
|
} catch (error) {
|
|
@@ -21,7 +21,7 @@ function isDeveloperAccount(userCid) {
|
|
|
21
21
|
/**
|
|
22
22
|
* Get developer override data for a user
|
|
23
23
|
* Auto-creates default document if it doesn't exist (for developer accounts only)
|
|
24
|
-
* Returns null if not a
|
|
24
|
+
* Returns null if not a developerg,
|
|
25
25
|
*/
|
|
26
26
|
async function getDevOverride(db, userCid, config, logger = null) {
|
|
27
27
|
if (!isDeveloperAccount(userCid)) {
|