bulltrackers-module 1.0.606 → 1.0.608
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.
|
@@ -1413,21 +1413,33 @@ const fetchAllReviewsForPI = async (db, piId, limit = 100) => {
|
|
|
1413
1413
|
|
|
1414
1414
|
// 2. Calculate Stats
|
|
1415
1415
|
let total = 0;
|
|
1416
|
-
const
|
|
1416
|
+
const counts = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 };
|
|
1417
1417
|
|
|
1418
1418
|
reviews.forEach(r => {
|
|
1419
1419
|
const rating = r.rating || 0;
|
|
1420
1420
|
total += rating;
|
|
1421
|
-
if(
|
|
1421
|
+
if(counts[rating] !== undefined) counts[rating]++;
|
|
1422
1422
|
});
|
|
1423
1423
|
|
|
1424
1424
|
const count = reviews.length;
|
|
1425
|
-
const avg = count > 0 ? (total / count).toFixed(2) : 0;
|
|
1425
|
+
const avg = count > 0 ? Number((total / count).toFixed(2)) : 0;
|
|
1426
|
+
|
|
1427
|
+
// Calculate percentages
|
|
1428
|
+
const percentages = {
|
|
1429
|
+
1: count > 0 ? Number((counts[1] / count * 100).toFixed(1)) : 0,
|
|
1430
|
+
2: count > 0 ? Number((counts[2] / count * 100).toFixed(1)) : 0,
|
|
1431
|
+
3: count > 0 ? Number((counts[3] / count * 100).toFixed(1)) : 0,
|
|
1432
|
+
4: count > 0 ? Number((counts[4] / count * 100).toFixed(1)) : 0,
|
|
1433
|
+
5: count > 0 ? Number((counts[5] / count * 100).toFixed(1)) : 0
|
|
1434
|
+
};
|
|
1426
1435
|
|
|
1427
1436
|
return {
|
|
1428
1437
|
count,
|
|
1429
1438
|
averageRating: avg,
|
|
1430
|
-
|
|
1439
|
+
ratingDistribution: {
|
|
1440
|
+
counts,
|
|
1441
|
+
percentages
|
|
1442
|
+
},
|
|
1431
1443
|
reviews
|
|
1432
1444
|
};
|
|
1433
1445
|
};
|
|
@@ -20,10 +20,12 @@ const PUBLIC_ROUTES = [
|
|
|
20
20
|
'/popular-investors/categories',
|
|
21
21
|
'/popular-investors/master-list',
|
|
22
22
|
'/popular-investors/search',
|
|
23
|
+
'/popular-investors/profile', // Public PI profiles - userCid optional for personalization
|
|
23
24
|
'/verification/lookup', // Uses Firebase Auth token instead of userCid
|
|
24
25
|
'/alerts/types', // Static data - doesn't need userCid
|
|
25
26
|
'/alerts/dynamic-watchlist-computations', // Static data - doesn't need userCid
|
|
26
|
-
'/popular-investors/track-view' // Optional userCid - can track views anonymously
|
|
27
|
+
'/popular-investors/track-view', // Optional userCid - can track views anonymously
|
|
28
|
+
'/reviews' // Public reviews - userCid optional (for showing current user's review)
|
|
27
29
|
];
|
|
28
30
|
|
|
29
31
|
const isPublicRoute = (path, originalUrl) => {
|
|
@@ -36,10 +38,21 @@ const isPublicRoute = (path, originalUrl) => {
|
|
|
36
38
|
if (fullPath === route || fullPath.includes(route)) {
|
|
37
39
|
return true;
|
|
38
40
|
}
|
|
39
|
-
// Pattern match for routes with parameters
|
|
41
|
+
// Pattern match for routes with parameters
|
|
42
|
+
// /popular-investors/:piId/profile or /popular-investors/:piId/track-view
|
|
43
|
+
if (route.includes('/profile') && fullPath.includes('/profile')) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
40
46
|
if (route.includes('/track-view') && fullPath.includes('/track-view')) {
|
|
41
47
|
return true;
|
|
42
48
|
}
|
|
49
|
+
// /reviews/:piId (but not /reviews/me or /reviews/:piId/eligibility)
|
|
50
|
+
if (route === '/reviews' && fullPath.startsWith('/reviews/')) {
|
|
51
|
+
// Exclude /reviews/me (requires auth) and /reviews/:piId/eligibility (requires auth)
|
|
52
|
+
if (!fullPath.startsWith('/reviews/me') && !fullPath.includes('/eligibility')) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
43
56
|
}
|
|
44
57
|
|
|
45
58
|
return false;
|