You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60Lines changed: 60 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ The SWE-bench website for leaderboards and project information.
21
21
-[How the Website Works](#how-the-website-works)
22
22
-[Build Process](#build-process)
23
23
-[Template System](#template-system)
24
+
-[Leaderboard Data Flow](#leaderboard-data-flow)
24
25
-[CSS Organization](#css-organization)
25
26
-[JavaScript Usage](#javascript-usage)
26
27
-[Customizing the Website](#customizing-the-website)
@@ -151,6 +152,65 @@ Templates use Jinja2 syntax for:
151
152
- Variable rendering (`{{ variable }}`)
152
153
- Control structures (`{% if condition %}{% endif %}`)
153
154
155
+
### Leaderboard Data Flow
156
+
157
+
The leaderboard data follows a specific flow from JSON to rendered HTML:
158
+
159
+
1.**Data Source**: All leaderboard data is stored in `data/leaderboards.json`. This JSON file contains an array of leaderboards under the key `"leaderboards"`, with each leaderboard having a `"name"` (e.g., "Test", "Lite", "Verified", "Multimodal") and a list of `"results"` entries.
160
+
161
+
2.**Data Loading**: During the build process in `build.py`, the JSON file is loaded and passed to the Jinja2 templates as the `leaderboards` variable:
162
+
```python
163
+
# From build.py
164
+
withopen(ROOT/"data/leaderboards.json", "r") as f:
165
+
leaderboards = json.load(f)
166
+
167
+
# Passed to templates during rendering
168
+
html = tpl.render(
169
+
title="SWE-bench",
170
+
leaderboards=leaderboards["leaderboards"]
171
+
)
172
+
```
173
+
174
+
3.**Reusable Table Component**: The `_leaderboard_table.html` template is a reusable component that loops through the leaderboards array and renders a table for each one:
{% for item in leaderboard.results if not item.warning %}
182
+
<tr>
183
+
<!-- Row data from each result item -->
184
+
</tr>
185
+
{% endfor %}
186
+
</tbody>
187
+
</table>
188
+
</div>
189
+
{% endfor %}
190
+
```
191
+
192
+
4.**Page-Specific Rendering**: In page templates like `lite.html`, the leaderboard data can be rendered in a more focused way by filtering for a specific leaderboard:
5.**Dynamic Badges and Formatting**: The templates add special badges and formatting to entries:
204
+
- Medal emoji (🥇, 🥈, 🥉) for the top 3 entries
205
+
- "New" badge (🆕) for recent submissions
206
+
- "Open source" badge (🤠) when `item.oss` is true
207
+
- "Verified" checkmark (✅) when `item.verified` is true
208
+
- Percentage formatting with 2 decimal places: `{{ "%.2f"|format(item.resolved|float) }}`
209
+
210
+
6.**JavaScript Enhancements**: After the HTML is rendered, JavaScript files like `mainResults.js`, `tableByRepo.js`, and `tableByYear.js` enhance the tables with sorting, filtering, and tab switching functionality.
211
+
212
+
This modular approach allows for easy updates to leaderboard data - simply modify the JSON file, and the changes will propagate throughout the site during the next build.
213
+
154
214
### CSS Organization
155
215
156
216
CSS is organized into modular files and imported through `main.css`:
0 commit comments