<commit_before>from req import Service
from service.base import BaseService
import config
import os
import re


class Submission(BaseService):
    def get_submission_list_admin(self, data={}):
        required_args = [{
            'name': '+count',
            'type': int,
        }, {
            'name': '+page',
            'type': int,
        }, {
            'name': 'user',
            'type': str,
        }, {
            'name': 'problem_id',
            'type': int,
        }, {
            'name': 'verdict',
            'type': int,
        }]
        err = self.form_validation(data, required_args)
        if err: return (err, None)
        where = {}
        if data['user'] is not None:
            pass
        if data['problem_id'] is not None:
            pass
        if data['verdict_id'] is not None:
            pass

        self.log(data)
        limit, offset = self.calc_limit_offset(data['page'], data['count'])
        res = yield self.db.execute("SELECT * FROM submissions ORDER BY id DESC LIMIT %s OFFSET %s", (limit, offset,))
        res = res.fetchall()
        return (None, res)

    def get_submission_list(self, data={}):
        required_args = [{
            'name': '+count',
            'type': int,
        }, {
            'name': '+page',
            'type': int,
        }]
        err = self.form_validation(data, required_args)
        if err: return (err, None)
        limit, offset = self.calc_limit_offset(data['page'], data['count'])
        res = yield self.db.execute("SELECT * FROM submissions WHERE user_id=%s ORDER BY id DESC LIMIT %s OFFSET %s", (data['user_id'], limit, offset,))
        res = res.fetchall()
        return (None, res)

    def get_submission(self, data={}):
        required_args = [{
            'name': '+id',
            'type': int,
        }]
        err = self.form_validation(data, required_args)
        if err: return (err, None)
        res = yield self.db.execute("SELECT * FROM submissions WHERE id=%s", (data['id'],))
        res = res.fetchone()
        return (None, res)

    def fixed_file_name(self, file_name):
        pass

    def post_submission_code(self, data={}):
        required_args = [{
            'name': '+problem_id',
            'type': int,
        }, {
            'name': '+user_id',
            'type': int,
        }, {
            'name': '+execute_type_id',
            'type': int,
        }, {
            'name': '+code',<commit_msg>add count to submission<commit_after>from req import Service
from service.base import BaseService
import config
import os
import re


class Submission(BaseService):
    def get_submission_list_admin(self, data={}):
        required_args = [{
            'name': '+count',
            'type': int,
        }, {
            'name': '+page',
            'type': int,
        }, {
            'name': 'user',
            'type': str,
        }, {
            'name': 'problem_id',
            'type': int,
        }, {
            'name': 'verdict',
            'type': int,
        }]
        err = self.form_validation(data, required_args)
        if err: return (err, None)
        where = {}
        if data['user'] is not None:
            pass
        if data['problem_id'] is not None:
            pass
        if data['verdict_id'] is not None:
            pass

        self.log(data)
        limit, offset = self.calc_limit_offset(data['page'], data['count'])
        res = {}
        res['data'] = (yield self.db.execute("SELECT * FROM submissions ORDER BY id DESC LIMIT %s OFFSET %s", (limit, offset,))).fetchall()
        res['count'] = (yield self.db.execute("SELECT COUNT(*) as count FROM submissions")).fetchone()
        return (None, res)

    def get_submission_list(self, data={}):
        required_args = [{
            'name': '+count',
            'type': int,
        }, {
            'name': '+page',
            'type': int,
        }]
        err = self.form_validation(data, required_args)
        if err: return (err, None)
        limit, offset = self.calc_limit_offset(data['page'], data['count'])
        res = {}
        res['data'] = (yield self.db.execute("SELECT * FROM submissions WHERE user_id=%s ORDER BY id DESC LIMIT %s OFFSET %s", (data['user_id'], limit, offset,))).fetchall()
        res['count'] = (yield self.db.execute("SELECT * FROM submissions WHERE user_id=%s", (data['user_id'],))).fetchone()
        return (None, res)

    def get_submission(self, data={}):
        required_args = [{
            'name': '+id',
            'type': int,
        }]
        err = self.form_validation(data, required_args)
        if err: return (err, None)
        res = yield self.db.execute("SELECT * FROM submissions WHERE id=%s", (data['id'],))
        res = res.fetchone()
        return (None, res)

    def fixed_file_name(self, file_name):
        pass

    def post_submission_code(self, data={}):
        required_args = [{
            'name': '+problem_id',
            'type': int,
        }, {
            'name': '+user_id',
            'type': int,
        }, {
            'name': '+execute_type_id',
            'type': int,
        }, {
            'name': '+code',
{'fraction_non_alphanumeric': 0.15039628842064565, 'fraction_numerical': 0.0, 'mean_word_length': 1.8319649698960043, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1050971', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1508, 'n_words': 396}