Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/apps/api/serializers/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class Meta:
'scores',
'display_name',
'slug_url',
'organization'
'organization',
'detailed_result'
)
extra_kwargs = {
"scores": {"read_only": True},
Expand Down
18 changes: 18 additions & 0 deletions src/apps/api/views/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ def get_leaderboard(self, request, pk):
}
columns = [col for col in query['columns']]
submissions_keys = {}
submission_detailed_results = {}
for submission in query['submissions']:

# count number of entries/number of submissions for the owner of this submission for this phase
Expand All @@ -529,12 +530,24 @@ def get_leaderboard(self, request, pk):
.strftime('%Y-%m-%d')

submission_key = f"{submission['owner']}{submission['parent'] or submission['id']}"

# gather detailed result from submissions for each task
# detailed_results are gathered based on submission key
# `id` is used to fetch the right detailed result in detailed results page
# `detailed_result` url is not needed
submission_detailed_results.setdefault(submission_key, []).append({
# 'detailed_result': submission['detailed_result'],
'task': submission['task'],
'id': submission['id']
})

if submission_key not in submissions_keys:
submissions_keys[submission_key] = len(response['submissions'])
response['submissions'].append({
'id': submission['id'],
'owner': submission['display_name'] or submission['owner'],
'scores': [],
'detailed_results': [],
'fact_sheet_answers': submission['fact_sheet_answers'],
'slug_url': submission['slug_url'],
'organization': submission['organization'],
Expand All @@ -559,6 +572,11 @@ def get_leaderboard(self, request, pk):
tempScore['score'] = str(round(float(tempScore["score"]), precision))
response['submissions'][submissions_keys[submission_key]]['scores'].append(tempScore)

# put detailed results in its submission
for k, v in submissions_keys.items():
response['submissions'][v]['detailed_results'] = submission_detailed_results[k]
print(f"\n{response['submissions']}\n")

for task in query['tasks']:
# This can be used to rendered variable columns on each task
tempTask = {
Expand Down
31 changes: 27 additions & 4 deletions src/static/riot/competitions/detail/leaderboards.tag
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
<th>Task:</th>
<th colspan=3></th>
<th each="{ task in filtered_tasks }" class="center aligned" colspan="{ task.colWidth }">{ task.name }</th>
<th if="{enable_detailed_results}"></th>
</tr>
<tr>
<th class="center aligned">#</th>
<th>Participant</th>
<th>Entries</th>
<th>Date of last entry</th>
<th each="{ column in filtered_columns }" colspan="1">{column.title}</th>
<th if="{enable_detailed_results}">Detailed Results</th>

</tr>
</thead>
<tbody>
Expand All @@ -60,8 +59,12 @@
<td>{submission.num_entries}</td>
<td>{submission.last_entry_date}</td>
<td if="{submission.organization !== null}"><a href="{submission.organization.url}">{ submission.organization.name }</a></td>
<td each="{ column in filtered_columns }">{ get_score(column, submission) } </td>
<td if="{enable_detailed_results}"><a href="detailed_results/{submission.id}" target="_blank">Show detailed results</a></td>
<td each="{ column in filtered_columns }">
<a if="{column.title == 'Detailed Results'}" href="detailed_results/{get_detailed_result_submisison_id(column, submission)}" target="_blank">Show detailed results</a>
<span if="{column.title != 'Detailed Results'}">{get_score(column, submission)}</span>
</td>


</tr>
</tbody>
</table>
Expand Down Expand Up @@ -101,6 +104,7 @@
self.filter_columns = () => {
let search_key = self.refs.leaderboardFilter.value.toLowerCase()
self.filtered_tasks = JSON.parse(JSON.stringify(self.selected_leaderboard.tasks))
console.log(self.filtered_tasks)
if(search_key){
self.filtered_columns = []
for (const column of self.columns){
Expand Down Expand Up @@ -143,17 +147,36 @@
self.selected_leaderboard.tasks.unshift(fake_metadata_task)
}
for(task of self.selected_leaderboard.tasks){

for(column of task.columns){
column.task_id = task.id
self.columns.push(column)
}
// -1 id is used for fact sheet answers
if(self.enable_detailed_results & task.id != -1){
self.columns.push({
task_id: task.id,
title: "Detailed Results"
})
task.colWidth += 1
}
console.log(task)
}
self.filter_columns()
$('#leaderboardTable').tablesort()
self.update()
})
}

self.get_detailed_result_submisison_id = function(column, submisison){
for (index in submisison.detailed_results) {
if(column.task_id == submisison.detailed_results[index].task){
return submisison.detailed_results[index].id
}
}
}


CODALAB.events.on('phase_selected', data => {
self.phase_id = data.id
self.update_leaderboard()
Expand Down