-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathmodel_utils.py
More file actions
33 lines (26 loc) · 1.13 KB
/
Copy pathmodel_utils.py
File metadata and controls
33 lines (26 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from datetime import datetime
from problem.models import Problem
from codechef.models import CodechefContest, CodechefContestProblems
def create_or_update_codechefProblem(problemdata):
for problem in problemdata:
Prob, created = Problem.objects.get_or_create(
prob_id=problem['ProblemCode'],
platform=problem['Platform'],
defaults={
'name': problem['Name'],
'url': problem['ProblemURL'],
'contest_id': problem['ContestId'],
},
)
cont = CodechefContest.objects.get(contestId=problem['ContestId'])
ccprob, created = CodechefContestProblems.objects.get_or_create(
contest=cont, problem=Prob)
def create_or_update_codechefContest(contest):
contestDate = datetime.strptime(contest['StartTime'], "%d %B %Y %H:%M:%S")
cont = CodechefContest.objects.get_or_create(
name=contest['Name'],
contestId=contest['ContestCode'],
duration=contest['Duration'],
startTime=contestDate,
url=contest['ContestURL'])
# create_or_update_codechefProblem(contest_problems_info)