Ejemplo n.º 1
0
                "user": self.user.id,
                "problem": self.problem.id,
                "timestamp": self.timestamp,
                "language": self.language,
                "code": self.code,
                "type": self.type,
                "results": self.results,
                "inputs": self.inputs[:self.problem.samples],
                "outputs": self.outputs[:self.problem.samples],
                "errors": self.errors[:self.problem.samples],
                "answers": self.answers[:self.problem.samples],
                "result": self.result
            }

    def forEach(callback: callable):
        with lock.gen_rlock():
            for id in submissions:
                callback(submissions[id])

    def onSave(callback: callable):
        Submission.saveCallbacks.append(callback)

    def all():
        with lock.gen_rlock():
            return [submissions[id] for id in submissions]


with lock.gen_wlock():
    for id in listSubKeys("/submissions"):
        submissions[id] = Submission(id)
Ejemplo n.º 2
0
                ) * 1000 <= contests[id].end:
                    return contests[id]
            return None

    def getFuture():
        with lock.gen_rlock():
            contest = None
            for id in contests:
                if contests[id].start > time.time() * 1000:
                    if not contest or contests[id].start < contest.start:
                        contest = contests[id]
            return contest

    def getPast():
        with lock.gen_rlock():
            contest = None
            for id in contests:
                if contests[id].end < time.time() * 1000:
                    if not contest or contests[id].end > contest.end:
                        contest = contests[id]
            return contest

    def all():
        with lock.gen_rlock():
            return [contests[id] for id in contests]


with lock.gen_wlock():
    for id in listSubKeys("/contests"):
        contests[id] = Contest(id)
Ejemplo n.º 3
0
        with lock.gen_rlock():
            json = self.toJSONSimple()
            json.sampleData = [datum.toJSON() for datum in self.sampleData]
            return json

    def toJSONFull(self):
        json = self.toJSONSimple()
        json["testData"] = [datum.toJSON() for datum in self.testData]
        return json

    def allJSON():
        with lock.gen_rlock():
            return [problems[id].toJSONSimple() for id in problems]

    def forEach(callback: callable):
        with lock.gen_rlock():
            for id in problems:
                callback(problems[id])

    def onSave(callback: callable):
        Problem.saveCallbacks.append(callback)

    def all():
        with lock.gen_rlock():
            return [problems[id] for id in problems]


with lock.gen_wlock():
    for id in listSubKeys("/problems"):
        problems[id] = Problem(id)
Ejemplo n.º 4
0
    def toJSON(self):
        with lock.gen_rlock():
            json = self.toJSONSimple()
            json.sampleData = [datum.toJSON() for datum in self.sampleData]
            return json
    
    def toJSONFull(self):
        json = self.toJSONSimple()
        json["testData"] = [datum.toJSON() for datum in self.testData]
        return json
    
    def allJSON():
        with lock.gen_rlock():
            return [problems[id].toJSONSimple() for id in problems]
    
    def forEach(callback: callable):
        with lock.gen_rlock():
            for id in problems:
                callback(problems[id])
    
    def onSave(callback: callable):
        Problem.saveCallbacks.append(callback)
    
    def all():
        with lock.gen_rlock():
            return [problems[id] for id in problems]

with lock.gen_wlock():
    for id in listSubKeys("/problems"):
        problems[id] = Problem(id)
Ejemplo n.º 5
0
        with lock.gen_wlock():
            deleteKey(f"/messages/{self.id}")
            del messages[self.id]
        
    def toJSON(self):
        return {
            "id":        self.id,
            "from":      self.fromUser.toJSON(),
            "to":        self.toUser.toJSON() if self.toUser else {},
            "general":   self.isGeneral,
            "admin":     self.isAdmin,
            "message":   self.message,
            "timestamp": self.timestamp
        }

    def forEach(callback: callable):
        with lock.gen_rlock():
            for id in messages:
                callback(messages[id])
    
    def onSave(callback: callable):
        Message.saveCallbacks.append(callback)
    
    def messagesSince(timestamp: float) -> list:
        with lock.gen_rlock():
            return [messages[id] for id in messages if messages[id].timestamp >= timestamp]

with lock.gen_wlock():
    for id in listSubKeys("/messages"):
        messages[id] = Message(id)
Ejemplo n.º 6
0
                "id":        self.id,
                "user":      self.user.id,
                "problem":   self.problem.id,
                "timestamp": self.timestamp,
                "language":  self.language,
                "code":      self.code,
                "type":      self.type,
                "results":   self.results,
                "inputs":    self.inputs[:self.problem.samples],
                "outputs":   self.outputs[:self.problem.samples],
                "errors":    self.errors[:self.problem.samples],
                "answers":   self.answers[:self.problem.samples],
                "result":    self.result
            }

    def forEach(callback: callable):
        with lock.gen_rlock():
            for id in submissions:
                callback(submissions[id])
    
    def onSave(callback: callable):
        Submission.saveCallbacks.append(callback)
    
    def all():
        with lock.gen_rlock():
            return [submissions[id] for id in submissions]

with lock.gen_wlock():
    for id in listSubKeys("/submissions"):
        submissions[id] = Submission(id)
Ejemplo n.º 7
0
            for id in contests:
                if contests[id].start <= time.time() * 1000 <= contests[id].end:
                    return contests[id]
            return None
    
    def getFuture():
        with lock.gen_rlock():
            contest = None
            for id in contests:
                if contests[id].start > time.time() * 1000:
                    if not contest or contests[id].start < contest.start:
                        contest = contests[id]
            return contest

    def getPast():
        with lock.gen_rlock():
            contest = None
            for id in contests:
                if contests[id].end < time.time() * 1000:
                    if not contest or contests[id].end > contest.end:
                        contest = contests[id]
            return contest
    
    def all():
        with lock.gen_rlock():
            return [contests[id] for id in contests]

with lock.gen_wlock():
    for id in listSubKeys("/contests"):
        contests[id] = Contest(id)