Spaces:
Running
Running
Sort leaderboards by trending_score; sort sections by list size
Browse files
client/src/components/LeaderboardSection/index.jsx
CHANGED
@@ -68,9 +68,19 @@ const LeaderboardSection = ({
|
|
68 |
}, [title, selectedLanguage, searchQuery]);
|
69 |
|
70 |
// Filtrer pour n'avoir que les leaderboards approuvés
|
71 |
-
const approvedLeaderboards =
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
// On ne retourne null que si on n'a pas de leaderboards bruts
|
76 |
if (!leaderboards) return null;
|
|
|
68 |
}, [title, selectedLanguage, searchQuery]);
|
69 |
|
70 |
// Filtrer pour n'avoir que les leaderboards approuvés
|
71 |
+
const approvedLeaderboards = useMemo(() => {
|
72 |
+
// Filtrer d'abord pour n'avoir que les leaderboards approuvés
|
73 |
+
const approved = filteredLeaderboards.filter(
|
74 |
+
(leaderboard) => leaderboard.approval_status === "approved"
|
75 |
+
);
|
76 |
+
|
77 |
+
// Trier par trending_score (ordre décroissant)
|
78 |
+
return [...approved].sort((a, b) => {
|
79 |
+
const scoreA = a.trending_score || 0;
|
80 |
+
const scoreB = b.trending_score || 0;
|
81 |
+
return scoreB - scoreA; // Tri décroissant
|
82 |
+
});
|
83 |
+
}, [filteredLeaderboards]);
|
84 |
|
85 |
// On ne retourne null que si on n'a pas de leaderboards bruts
|
86 |
if (!leaderboards) return null;
|
client/src/context/LeaderboardContext.jsx
CHANGED
@@ -164,6 +164,20 @@ export const LeaderboardProvider = ({ children }) => {
|
|
164 |
return allSections.filter((section) => section.data.length > 0);
|
165 |
}, [allSections]);
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
// Calculate total number of unique leaderboards (excluding duplicates)
|
168 |
const totalLeaderboards = useMemo(() => {
|
169 |
const uniqueIds = new Set(
|
@@ -241,6 +255,7 @@ export const LeaderboardProvider = ({ children }) => {
|
|
241 |
filterLeaderboards,
|
242 |
filterLeaderboardsForCount,
|
243 |
sections,
|
|
|
244 |
allSections,
|
245 |
getHighlightedText,
|
246 |
selectedCategories,
|
|
|
164 |
return allSections.filter((section) => section.data.length > 0);
|
165 |
}, [allSections]);
|
166 |
|
167 |
+
// Sections triées par nombre de leaderboards (pour l'affichage sur la page d'accueil)
|
168 |
+
const sectionsSortedByCount = useMemo(() => {
|
169 |
+
return [...sections].sort((a, b) => {
|
170 |
+
// Filtrer pour n'avoir que les leaderboards approuvés
|
171 |
+
const approvedA = a.data.filter(
|
172 |
+
(board) => board.approval_status === "approved"
|
173 |
+
);
|
174 |
+
const approvedB = b.data.filter(
|
175 |
+
(board) => board.approval_status === "approved"
|
176 |
+
);
|
177 |
+
return approvedB.length - approvedA.length; // Tri décroissant
|
178 |
+
});
|
179 |
+
}, [sections]);
|
180 |
+
|
181 |
// Calculate total number of unique leaderboards (excluding duplicates)
|
182 |
const totalLeaderboards = useMemo(() => {
|
183 |
const uniqueIds = new Set(
|
|
|
255 |
filterLeaderboards,
|
256 |
filterLeaderboardsForCount,
|
257 |
sections,
|
258 |
+
sectionsSortedByCount,
|
259 |
allSections,
|
260 |
getHighlightedText,
|
261 |
selectedCategories,
|
client/src/pages/HowToSubmitPage/HowToSubmitPage.jsx
CHANGED
@@ -728,14 +728,14 @@ const HowToSubmitPage = () => {
|
|
728 |
title="Domain"
|
729 |
description="Indicates the specific domain of the leaderboard:"
|
730 |
tags={[
|
731 |
-
"domain:financial",
|
732 |
"domain:medical",
|
733 |
-
"domain:legal",
|
734 |
-
"domain:biology",
|
735 |
-
"domain:translation",
|
736 |
"domain:chemistry",
|
737 |
"domain:physics",
|
|
|
|
|
|
|
738 |
"domain:commercial",
|
|
|
739 |
]}
|
740 |
/>
|
741 |
|
|
|
728 |
title="Domain"
|
729 |
description="Indicates the specific domain of the leaderboard:"
|
730 |
tags={[
|
|
|
731 |
"domain:medical",
|
|
|
|
|
|
|
732 |
"domain:chemistry",
|
733 |
"domain:physics",
|
734 |
+
"domain:biology",
|
735 |
+
"domain:financial",
|
736 |
+
"domain:legal",
|
737 |
"domain:commercial",
|
738 |
+
"domain:translation",
|
739 |
]}
|
740 |
/>
|
741 |
|
client/src/pages/LeaderboardPage/LeaderboardPage.jsx
CHANGED
@@ -18,6 +18,7 @@ const LeaderboardPageContent = () => {
|
|
18 |
filterLeaderboards,
|
19 |
sections,
|
20 |
allSections,
|
|
|
21 |
searchQuery,
|
22 |
arenaOnly,
|
23 |
selectedCategories,
|
@@ -272,8 +273,9 @@ const LeaderboardPageContent = () => {
|
|
272 |
)
|
273 |
) : (
|
274 |
// Si aucune catégorie n'est sélectionnée, on affiche toutes les sections avec des résultats
|
|
|
275 |
(hasLeaderboards || !isFiltering) &&
|
276 |
-
|
277 |
const filteredLeaderboards = filterLeaderboards(data);
|
278 |
if (filteredLeaderboards.length === 0) return null;
|
279 |
return (
|
|
|
18 |
filterLeaderboards,
|
19 |
sections,
|
20 |
allSections,
|
21 |
+
sectionsSortedByCount,
|
22 |
searchQuery,
|
23 |
arenaOnly,
|
24 |
selectedCategories,
|
|
|
273 |
)
|
274 |
) : (
|
275 |
// Si aucune catégorie n'est sélectionnée, on affiche toutes les sections avec des résultats
|
276 |
+
// triées par nombre de leaderboards
|
277 |
(hasLeaderboards || !isFiltering) &&
|
278 |
+
sectionsSortedByCount.map(({ id, title, data }) => {
|
279 |
const filteredLeaderboards = filterLeaderboards(data);
|
280 |
if (filteredLeaderboards.length === 0) return null;
|
281 |
return (
|