Add tier field to judge model

This commit is contained in:
Quantum 2024-08-21 01:03:15 -04:00 committed by Guanzhong Chen
parent 8cebcedfa2
commit 795d19131d
3 changed files with 24 additions and 2 deletions

View File

@ -65,12 +65,12 @@ class JudgeAdmin(VersionAdmin):
readonly_fields = ('created', 'online', 'start_time', 'ping', 'load', 'last_ip', 'runtimes', 'problems',
'is_disabled')
fieldsets = (
(None, {'fields': ('name', 'auth_key', 'is_blocked', 'is_disabled')}),
(None, {'fields': ('name', 'auth_key', 'is_blocked', 'is_disabled', 'tier')}),
(_('Description'), {'fields': ('description',)}),
(_('Information'), {'fields': ('created', 'online', 'last_ip', 'start_time', 'ping', 'load')}),
(_('Capabilities'), {'fields': ('runtimes',)}),
)
list_display = ('name', 'online', 'is_disabled', 'start_time', 'ping', 'load', 'last_ip')
list_display = ('name', 'online', 'is_disabled', 'tier', 'start_time', 'ping', 'load', 'last_ip')
ordering = ['-online', 'name']
formfield_overrides = {
TextField: {'widget': AdminMartorWidget},

View File

@ -0,0 +1,19 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('judge', '0146_comment_revision_count_v2'),
]
operations = [
migrations.AddField(
model_name='judge',
name='tier',
field=models.PositiveIntegerField(
default=1,
help_text='The tier of this judge. Only online judges of the minimum tier will be used. This is used for high-availability.',
verbose_name='judge tier',
),
),
]

View File

@ -131,6 +131,9 @@ class Judge(models.Model):
'even if its key is correct.'))
is_disabled = models.BooleanField(verbose_name=_('disable judge'), default=False,
help_text=_('Whether this judge should be removed from judging queue.'))
tier = models.PositiveIntegerField(verbose_name=_('judge tier'), default=1,
help_text=_('The tier of this judge. Only online judges of the minimum tier '
'will be used. This is used for high-availability.'))
online = models.BooleanField(verbose_name=_('judge online status'), default=False)
start_time = models.DateTimeField(verbose_name=_('judge start time'), null=True)
ping = models.FloatField(verbose_name=_('response time'), null=True)