Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop into master #1674

Merged
merged 17 commits into from
Nov 19, 2024
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
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ services:
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
- POSTGRES_PASSWORD=${DB_PASSWORD}
command: ["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]
ports:
- 5432:5432
volumes:
Expand Down
2 changes: 1 addition & 1 deletion src/apps/api/serializers/submission_leaderboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SubmissionLeaderBoardSerializer(serializers.ModelSerializer):
display_name = serializers.CharField(source='owner.display_name')
slug_url = serializers.CharField(source='owner.slug_url')
organization = SimpleOrganizationSerializer(allow_null=True)
created_when = serializers.DateTimeField(format="%Y-%m-%d %H:%M")
created_when = serializers.DateTimeField()

class Meta:
model = Submission
Expand Down
2 changes: 1 addition & 1 deletion src/apps/api/serializers/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SubmissionSerializer(serializers.ModelSerializer):
phase_name = serializers.CharField(source='phase.name')
on_leaderboard = serializers.BooleanField(read_only=True)
task = TaskSerializer()
created_when = serializers.DateTimeField(format="%Y-%m-%d %H:%M")
created_when = serializers.DateTimeField()
auto_run = serializers.SerializerMethodField(read_only=True)
can_make_submissions_public = serializers.SerializerMethodField(read_only=True)

Expand Down
2 changes: 2 additions & 0 deletions src/apps/api/views/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def competitions_usage(request):

query = CompetitionStorageDataPoint.objects.filter(
at_date__range=(start_date, end_date),
competition__isnull=False
).dates("at_date", resolution).values(
'id',
'competition__id',
Expand Down Expand Up @@ -267,6 +268,7 @@ def users_usage(request):

query = UserStorageDataPoint.objects.filter(
at_date__range=(start_date, end_date),
user__isnull=False
).dates("at_date", resolution).values(
'id',
'user__id',
Expand Down
25 changes: 12 additions & 13 deletions src/apps/api/views/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from leaderboards.models import Leaderboard
from utils.data import make_url_sassy
from api.permissions import IsOrganizerOrCollaborator
from datetime import datetime
from django.db import transaction
from django.conf import settings

Expand Down Expand Up @@ -271,8 +270,8 @@ def update(self, request, *args, **kwargs):
new_phase_obj = Phase.objects.create(
status=phase["status"],
index=phase["index"],
start=datetime.strptime(phase['start'], "%B %d, %Y"),
end=datetime.strptime(phase['end'], "%B %d, %Y") if phase['end'] else None,
start=phase['start'],
end=phase['end'] if phase['end'] else None,
name=phase["name"],
description=phase["description"],
hide_output=phase["hide_output"],
Expand Down Expand Up @@ -706,15 +705,15 @@ def get_leaderboard(self, request, pk):
# - child submissions (submissions who has a parent i.e. parent field is not null)
# - Failed submissions
# - Cancelled submissions
num_entries = Submission.objects.filter(
Q(owner__username=submission['owner']) |
Q(parent__owner__username=submission['owner']),
phase=phase,
).exclude(
Q(status=Submission.FAILED) |
Q(status=Submission.CANCELLED) |
Q(parent__isnull=False)
).count()
# num_entries = Submission.objects.filter(
# Q(owner__username=submission['owner']) |
# Q(parent__owner__username=submission['owner']),
# phase=phase,
# ).exclude(
# Q(status=Submission.FAILED) |
# Q(status=Submission.CANCELLED) |
# Q(parent__isnull=False)
# ).count()

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

Expand All @@ -738,7 +737,7 @@ def get_leaderboard(self, request, pk):
'fact_sheet_answers': submission['fact_sheet_answers'],
'slug_url': submission['slug_url'],
'organization': submission['organization'],
'num_entries': num_entries,
# 'num_entries': num_entries,
'created_when': submission['created_when']
})
for score in submission['scores']:
Expand Down
2 changes: 1 addition & 1 deletion src/static/riot/competitions/detail/_tabs.tag
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
})

self.pretty_date = function (date_string) {
if (!!date_string) {
if (date_string != null) {
return luxon.DateTime.fromISO(date_string).toLocaleString(luxon.DateTime.DATETIME_FULL)
} else {
return ''
Expand Down
11 changes: 8 additions & 3 deletions src/static/riot/competitions/detail/leaderboards.tag
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<tr>
<th class="center aligned">#</th>
<th>Participant</th>
<th>Entries</th>
<th>Date</th>
<th>ID</th>
<th each="{ column in filtered_columns }" colspan="1">{column.title}</th>
Expand Down Expand Up @@ -83,8 +82,7 @@
</td>
<td if="{submission.organization === null}"><a href="{submission.slug_url}">{ submission.owner }</a></td>
<td if="{submission.organization !== null}"><a href="{submission.organization.url}">{ submission.organization.name }</a></td>
<td>{submission.num_entries}</td>
<td>{submission.created_when}</td>
<td>{ pretty_date(submission.created_when) }</td>
<td>{submission.id}</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" class="eye-icon-link">
Expand All @@ -108,6 +106,13 @@
self.enable_detailed_results = false
self.show_detailed_results_in_leaderboard = false

self.pretty_date = function (date_string) {
if (!!date_string) {
return luxon.DateTime.fromISO(date_string).toFormat('yyyy-MM-dd HH:mm')
} else {
return ''
}
}

self.bold_class = function(column, submission){
// Return `text-bold` if submission has
Expand Down
14 changes: 12 additions & 2 deletions src/static/riot/competitions/detail/submission_manager.tag
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<td>{ submission.filename }</td>
<td if="{ opts.admin }">{ submission.owner }</td>
<td if="{ opts.admin }">{ submission.phase.name }</td>
<td>{ submission.created_when}</td>
<td>{ pretty_date(submission.created_when) }</td>
<td class="right aligned collapsing">
{ submission.status }
<sup data-tooltip="{submission.status_details}">
Expand Down Expand Up @@ -201,6 +201,8 @@
<script>
var self = this



self.selected_phase = undefined
self.selected_submission = undefined
self.hide_output = false
Expand All @@ -217,6 +219,14 @@
$(self.refs.submission_table).tablesort()
})

self.pretty_date = function (date_string) {
if (!!date_string) {
return luxon.DateTime.fromISO(date_string).toFormat('yyyy-MM-dd HH:mm')
} else {
return ''
}
}

self.is_admin = () => {
return _.get(self.selected_submission, 'admin', false)
}
Expand Down Expand Up @@ -607,4 +617,4 @@
.failed.question.circle.icon
color #2c3f4c
</style>
</submission-manager>
</submission-manager>
Loading