bulltrackers-module 1.0.671 → 1.0.672
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.
|
@@ -2050,24 +2050,52 @@ const fetchUserRecommendations = async (db, userId) => {
|
|
|
2050
2050
|
const fetchTrendingPopularInvestors = async (db) => {
|
|
2051
2051
|
// Path: /unified_insights/{DATE}/results/popular-investor/computations/TrendingPopularInvestors
|
|
2052
2052
|
const today = new Date().toISOString().split('T')[0];
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2053
|
+
|
|
2054
|
+
// Try today first, then look back up to 7 days
|
|
2055
|
+
for (let i = 0; i < 7; i++) {
|
|
2056
|
+
const checkDate = new Date(today);
|
|
2057
|
+
checkDate.setDate(checkDate.getDate() - i);
|
|
2058
|
+
const dateKey = checkDate.toISOString().split('T')[0];
|
|
2059
|
+
|
|
2060
|
+
try {
|
|
2061
|
+
const result = await getComputationResults(db, 'TrendingPopularInvestors', dateKey);
|
|
2062
|
+
if (result && result.trending && Array.isArray(result.trending) && result.trending.length > 0) {
|
|
2063
|
+
return result.trending;
|
|
2064
|
+
}
|
|
2065
|
+
} catch (e) {
|
|
2066
|
+
// Continue to next date
|
|
2067
|
+
if (i === 6) {
|
|
2068
|
+
console.warn(`[Trending] Failed to fetch after 7 day lookback: ${e.message}`);
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2059
2071
|
}
|
|
2072
|
+
|
|
2073
|
+
return [];
|
|
2060
2074
|
};
|
|
2061
2075
|
|
|
2062
2076
|
const fetchPopularInvestorCategories = async (db) => {
|
|
2063
2077
|
const today = new Date().toISOString().split('T')[0];
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2078
|
+
|
|
2079
|
+
// Try today first, then look back up to 7 days
|
|
2080
|
+
for (let i = 0; i < 7; i++) {
|
|
2081
|
+
const checkDate = new Date(today);
|
|
2082
|
+
checkDate.setDate(checkDate.getDate() - i);
|
|
2083
|
+
const dateKey = checkDate.toISOString().split('T')[0];
|
|
2084
|
+
|
|
2085
|
+
try {
|
|
2086
|
+
const result = await getComputationResults(db, 'PopularInvestorCategories', dateKey);
|
|
2087
|
+
if (result && result.categories && typeof result.categories === 'object' && Object.keys(result.categories).length > 0) {
|
|
2088
|
+
return result.categories;
|
|
2089
|
+
}
|
|
2090
|
+
} catch (e) {
|
|
2091
|
+
// Continue to next date
|
|
2092
|
+
if (i === 6) {
|
|
2093
|
+
console.warn(`[Categories] Failed to fetch after 7 day lookback: ${e.message}`);
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2070
2096
|
}
|
|
2097
|
+
|
|
2098
|
+
return {};
|
|
2071
2099
|
};
|
|
2072
2100
|
|
|
2073
2101
|
|