Beispiel #1
0
def get_lang_id(file):
    """
    File extension validator and identificator
    :param file: Input file
    :return: Language ID, if extension is valid, or None.
    """
    from lib.database import db_session
    from models import Language

    filename, ext = os.path.splitext(file)
    return db_session.query(Language.id).filter_by(file_ext=ext).first()
Beispiel #2
0
def problemset(page):
    """
    Problems list
    """
    from models import Problem, Solution
    from lib.database import db_session
    from lib.pagination import Pagination

    per_page = centipede.config['PER_PAGE']
    total = Problem.query.count()
    problems = db_session.query(Problem.id, Problem.title).order_by(Problem.id).\
        limit(per_page).offset((page - 1) * per_page).all()
    pagination = Pagination(page, per_page, total)

    for problem in problems:
        problem.total = Solution.query.filter_by(problem_id = problem.id).count()
        problem.success = Solution.query.filter_by(
            problem_id = problem.id,
            status = Solution.STATUS['tested']['accept']
        ).count()
    return render_template('problemset.html', problems = problems, active_problems = True, pagination = pagination)
Beispiel #3
0
 def find_one(cls, id):
     return db_session.query(
         cls
     ).filter(cls.id == id).first()
Beispiel #4
0
 def find_all_id(cls):
     return db_session.query(
         cls.id
     ).filter(cls.id > 10798).all()
Beispiel #5
0
 def find_all(cls):
     return db_session.query(
         cls
     ).filter().all()
Beispiel #6
0
 def find_by_logId(cls, log_id):
     return db_session.query(cls).filter(cls.log_id == log_id).first()