}, { "value": "fail", "count": val[2] }] } time = {} time["min"], time["sec"] = values.get("time", (0, 0)) return {"scores": scores, "time": time} xsumo_single_data = data(lambda: [ model.Team(id=1, name="Sumojoukkue 1"), model.Team(id=2, name="Sumojoukkue 2"), model.Judge(id=1, name="Sumotuomari A", key="a"), model.Event(id=1, block_id="xsumo.as", ts_sched=0, arena="xsumo.1", teams_part= [model.EventTeam(team_id=1), model.EventTeam(team_id=2)], judgings=[model.EventJudging(judge_id=1)]) ]) rescue_data = data(lambda: [ model.Team(id=1, name="Rescuejoukkue 1"), model.Judge(id=1, name="Tuomari A", key="a"), model.Judge(id=2, name="Tuomari B", key="b"), model.Event(id=1,
def import_command(db, strict, y, **kwargs): timetable = parse_timetable(kwargs["file"].read(), time_fmt=kwargs["datefmt"]) if not timetable: return k = len(timetable[0]) - kwargs["j"] - 1 teams = set(timetable[:, 1:1 + k].labels) judges = set(timetable[:, 1 + k:].labels) autoconfirm = False if strict else (True if y else None) teams = insert_missing_interactive( db, model.Team, teams, creator=lambda name: model.Team(name=name, is_shadow=name.startswith("::")), autoconfirm=autoconfirm) judges = insert_missing_interactive( db, model.Judge, judges, creator=lambda name: model.Judge(name=name), autoconfirm=autoconfirm) teams = dict((t.name, t) for t in teams) judges = dict((j.name, j) for j in judges) events = [] for e in timetable: event = model.Event(block_id=kwargs["block"], ts_sched=int(e.time.timestamp()), arena=e[0].name, teams_part=[ model.EventTeam(team_id=teams[l.name].id) for l in e[1:1 + k] ], judgings=[ model.EventJudging(judge_id=judges[l.name].id) for l in e[1 + k:] ]) #print([teams[l.name].id for l in e[1:1+k]]) #event.team_ids.extend(teams[l.name].id for l in e[1:1+k]) #event.judge_ids.extend(judges[l.name].id for l in e[1+k:]) events.append(event) db.add_all(events) try: db.commit() except IntegrityError: # TODO tähän joku hyödyllisempi virhe, etsi vaikka mitkä eventit aiheuttaa ongelmia db.rollback() raise RsxError("Block conflict") click.echo("%s Added %d events to block %s" % (click.style( "[+]", fg="green", bold=True), len(events), kwargs["block"]))
def app(init_app): init_app.register_blueprint( TimetableView().create_blueprint(name="timetable"), url_prefix="/timetable") init_app.register_blueprint( TimetableShadows().create_blueprint(name="timetableshadows"), url_prefix="/timetable-shadows") return init_app timetable_data = data(lambda: [ model.Team(id=1, name="Sumojoukkue 1"), model.Team(id=2, name="Sumojoukkue 2"), model.Team(id=3, name="Rescue-joukkue 1"), model.Team(id=4, name="Rescue-joukkue 2", is_shadow=1), model.Judge(id=1, name="Tuomari A"), model.Event(id=1, block_id="xsumo.as", ts_sched=0, arena="xsumo.1", teams_part= [model.EventTeam(team_id=1), model.EventTeam(team_id=2)], judgings=[model.EventJudging(judge_id=1)]), model.Event(id=2, block_id="rescue1.a", ts_sched=1, arena="rescue.1", teams_part=[model.EventTeam(team_id=3)], judgings=[model.EventJudging(judge_id=1)]), model.Event(id=3,
import pytest from sqlalchemy.orm import subqueryload from sqlalchemy.exc import IntegrityError import robostat import robostat.db as model from robostat.util import enumerate_rank from robostat.rulesets.xsumo import XSRuleset from .helpers import XS2, R, data, make_event tj_data = data(lambda: [ model.Team(id=1, name="Joukkue A"), model.Team(id=2, name="Joukkue B"), model.Team(id=3, name="Joukkue C"), model.Team(id=4, name="Joukkue D", is_shadow=1), model.Judge(id=1, name="Tuomari A"), model.Judge(id=2, name="Tuomari B") ]) xsumo_events = data(lambda: [ make_event(teams=[1, 2], judges=[1], block_id="xsumo", ts_sched=0, arena="xsumo.1"), make_event(teams=[2, 3], judges=[1], block_id="xsumo", ts_sched=1, arena="xsumo.1"), make_event(teams=[3, 1], judges=[1],
def create_judge(json): judge = parse_judge(model.Judge(), json) db.add(judge) commit() return {**jsonify(judge), "key": judge.key}