mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-28 16:12:13 +00:00
add judge server status field
This commit is contained in:
parent
d1e505dc24
commit
0fe5b10418
@ -1,4 +1,5 @@
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
class SMTPConfig(models.Model):
|
||||
@ -38,6 +39,12 @@ class JudgeServer(models.Model):
|
||||
task_number = models.IntegerField(default=0)
|
||||
service_url = models.CharField(max_length=128, blank=True, null=True)
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
if (timezone.now() - self.last_heartbeat).total_seconds() > 5:
|
||||
return "abnormal"
|
||||
return "normal"
|
||||
|
||||
class Meta:
|
||||
db_table = "judge_server"
|
||||
|
||||
|
@ -43,6 +43,7 @@ class WebsiteConfigSerializer(serializers.ModelSerializer):
|
||||
class JudgeServerSerializer(serializers.ModelSerializer):
|
||||
create_time = DateTimeTZField()
|
||||
last_heartbeat = DateTimeTZField()
|
||||
status = serializers.CharField()
|
||||
|
||||
class Meta:
|
||||
model = JudgeServer
|
||||
|
Loading…
Reference in New Issue
Block a user