def handle(self, *args, **options): for profile in Profile.objects.all(): print(profile.name) if not profile.spojId: print('No SPOJ user.\n') continue s = Spoj(profile.spojId) solutions = s.getSolutions() print("%d solutions." % len(solutions)) for s in solutions: try: problem = Problem.objects.get(code=s['code'], judge='spoj') except Problem.DoesNotExist: print('SPOJ is missing problem: ', s['code']) continue try: solution = Solution.objects.get(problem=problem, profile=profile) except Solution.DoesNotExist: solution = Solution() if not solution.date or s['date'] < solution.date: solution.date = s['date'] solution.problem = problem solution.profile = profile solution.save() print()
def handle(self, *args, **options): for profile in Profile.objects.all(): print(profile.name) if not profile.uvaId: print('No UVa user.\n') continue u = Uva(profile.uvaId) solutions = u.getSolutions().items() print("%d solutions." % len(solutions)) for code, time in solutions: problem = Problem.objects.get(code=code, judge='uva') try: solution = Solution.objects.get(problem=problem, profile=profile) except Solution.DoesNotExist: solution = Solution() solution.date = datetime.fromtimestamp(time) solution.problem = problem solution.profile = profile solution.save() print()
def createSolution(profile, problem, date): solution = Solution() solution.profile = profile solution.problem = problem solution.date = date solution.save()