Spaces:
Running
Running
Commit
·
da194bd
1
Parent(s):
a1b46a8
loading
Browse files- src/routes/Leaderboard.svelte +29 -18
src/routes/Leaderboard.svelte
CHANGED
|
@@ -19,26 +19,32 @@
|
|
| 19 |
const baseUrl = "https://huggingface.co/datasets/dylanebert/3d-arena/resolve/main/outputs";
|
| 20 |
let leaderboard: Entry[] = [];
|
| 21 |
let filteredLeaderboard: Entry[] = [];
|
|
|
|
| 22 |
|
| 23 |
const fetchLeaderboardData = async () => {
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
data
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
};
|
| 43 |
|
| 44 |
const updateFilteredLeaderboard = () => {
|
|
@@ -62,7 +68,12 @@
|
|
| 62 |
});
|
| 63 |
</script>
|
| 64 |
|
| 65 |
-
{#if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
<div class="grid">
|
| 67 |
{#each filteredLeaderboard as entry, index}
|
| 68 |
<button class="grid-item" on:click={() => onEntryClick(entry)}>
|
|
|
|
| 19 |
const baseUrl = "https://huggingface.co/datasets/dylanebert/3d-arena/resolve/main/outputs";
|
| 20 |
let leaderboard: Entry[] = [];
|
| 21 |
let filteredLeaderboard: Entry[] = [];
|
| 22 |
+
let isLoading = false;
|
| 23 |
|
| 24 |
const fetchLeaderboardData = async () => {
|
| 25 |
+
isLoading = true;
|
| 26 |
+
try {
|
| 27 |
+
const url = `/api/leaderboard?vote_type=${voteType}`;
|
| 28 |
+
const response = await fetch(url, {
|
| 29 |
+
method: "GET",
|
| 30 |
+
headers: {
|
| 31 |
+
"Cache-Control": "no-cache",
|
| 32 |
+
},
|
| 33 |
+
});
|
| 34 |
+
const data = (await response.json()) as Entry[];
|
| 35 |
+
const entriesWithDisplayNames = await Promise.all(
|
| 36 |
+
data.map(async (entry) => {
|
| 37 |
+
const config = await getConfig(entry.name);
|
| 38 |
+
return { ...entry, displayName: config.DisplayName || entry.name };
|
| 39 |
+
}),
|
| 40 |
+
);
|
| 41 |
+
entriesWithDisplayNames.sort((a, b) => a.rank - b.rank);
|
| 42 |
|
| 43 |
+
leaderboard = entriesWithDisplayNames;
|
| 44 |
+
updateFilteredLeaderboard();
|
| 45 |
+
} finally {
|
| 46 |
+
isLoading = false;
|
| 47 |
+
}
|
| 48 |
};
|
| 49 |
|
| 50 |
const updateFilteredLeaderboard = () => {
|
|
|
|
| 68 |
});
|
| 69 |
</script>
|
| 70 |
|
| 71 |
+
{#if isLoading}
|
| 72 |
+
<div class="loading-container">
|
| 73 |
+
<ProgressBarRound class="loading-icon" />
|
| 74 |
+
<div class="loading-text">Loading...</div>
|
| 75 |
+
</div>
|
| 76 |
+
{:else if filteredLeaderboard.length > 0}
|
| 77 |
<div class="grid">
|
| 78 |
{#each filteredLeaderboard as entry, index}
|
| 79 |
<button class="grid-item" on:click={() => onEntryClick(entry)}>
|