migrate to postgres json field
This commit is contained in:
41
problem/migrations/0009_auto_20171011_1214.py
Normal file
41
problem/migrations/0009_auto_20171011_1214.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.4 on 2017-10-11 12:14
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.contrib.postgres.fields.jsonb
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('problem', '0008_auto_20170923_1318'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='problem',
|
||||
name='languages',
|
||||
field=django.contrib.postgres.fields.jsonb.JSONField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='problem',
|
||||
name='samples',
|
||||
field=django.contrib.postgres.fields.jsonb.JSONField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='problem',
|
||||
name='statistic_info',
|
||||
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='problem',
|
||||
name='template',
|
||||
field=django.contrib.postgres.fields.jsonb.JSONField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='problem',
|
||||
name='test_case_score',
|
||||
field=django.contrib.postgres.fields.jsonb.JSONField(),
|
||||
),
|
||||
]
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.db import models
|
||||
from jsonfield import JSONField
|
||||
from utils.models import JSONField
|
||||
|
||||
from account.models import User
|
||||
from contest.models import Contest
|
||||
@@ -66,7 +66,7 @@ class Problem(models.Model):
|
||||
submission_number = models.BigIntegerField(default=0)
|
||||
accepted_number = models.BigIntegerField(default=0)
|
||||
# ACM rule_type: {JudgeStatus.ACCEPTED: 3, JudgeStaus.WRONG_ANSWER: 11}, the number means count
|
||||
statistic_info = JSONField(default={})
|
||||
statistic_info = JSONField(default=dict)
|
||||
|
||||
class Meta:
|
||||
db_table = "problem"
|
||||
|
||||
@@ -55,9 +55,9 @@ class ProblemAPI(APIView):
|
||||
oi_problems_status = profile.oi_problems_status.get("problems", {})
|
||||
for problem in data["results"]:
|
||||
if problem["rule_type"] == ProblemRuleType.ACM:
|
||||
problem["my_status"] = acm_problems_status.get(str(problem["id"]), None)
|
||||
problem["my_status"] = acm_problems_status.get(str(problem["id"]), {}).get("status")
|
||||
else:
|
||||
problem["my_status"] = oi_problems_status.get(str(problem["id"]), None)
|
||||
problem["my_status"] = oi_problems_status.get(str(problem["id"]), {}).get("status")
|
||||
return self.success(data)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user