def getContestProblem(self, cid):

        whereclause = ' cid = {} '.format(cid)
        sql = getQuerySQL('cproblem', whereclause, ' cpid ')
        rs = FetchAll(sql)

        return rs
示例#2
0
    def getSubmitInfo(self, uid):

        sql = 'SELECT status,count(status) from status WHERE uid = {} GROUP BY status ORDER BY status'.format(
            uid)
        rs = FetchAll(sql)

        return rs
示例#3
0
    def getMsgs(self, Data):
        '''
        for key in Data :
            print(key,' ----> ',Data[key])
        '''

        wherecluse = ''

        for key in Data:
            if key == 'index':
                continue
            else:
                if len(wherecluse) != 0:
                    wherecluse += ' and '
                wherecluse += ' {} like "%{}%" '.format(key, Data[key])

        ordercluse = ' timesubmit desc '

        sql = getPageLimitSQL('status', wherecluse, ordercluse, Data['index'],
                              21)

        print(sql)
        rs = FetchAll(sql)

        return rs
示例#4
0
    def getProblemList(self, cid, uid):
        wherecluse = ' cid = {} '.format(cid)
        ordclause = ' cpid '

        sql = getQuerySQL(' cproblem ', wherecluse, ordclause)

        print(sql)
        rs = FetchAll(sql)

        ac = [0 for i in range(len(rs))]
        tr = [0 for i in range(len(rs))]

        for i in range(len(rs)):
            if uid is not None:
                ac[i] = CheckContestIfAccept(uid, rs[i][2], cid)[0]
                if ac[i] == 1: tr[i] = 1
                else: tr[i] = CheckContestIfTry(uid, rs[i][2], cid)[0]

        totalsubmit = CountContestSubmitNum(cid)
        acsubmit = CountContestACNum(cid)

        td = dict()
        ad = dict()
        for x in totalsubmit:
            td[x[0]] = x[1]
        for x in acsubmit:
            ad[x[0]] = x[1]
        '''
        print(rs)
        print(ac)
        print(td)
        print(ad)
        '''

        return rs, ac, td, ad, tr
示例#5
0
    def getContests(self, uid):
        whereclause = ' cuid = {}'.format(uid)
        ordclause = ' cid desc '

        sql = getPageLimitSQL('contest', whereclause, ordclause, 0, 100000)
        rs = FetchAll(sql)

        return rs
示例#6
0
    def getStatusInfo(self, cid):

        whereclause = ' cid = {} '.format(cid)
        ordclause = ' sid '

        sql = getQuerySQL('status',
                          whereclause=whereclause,
                          ordclause=ordclause)
        rs = FetchAll(sql)

        return rs
示例#7
0
    def getContestsDetail(self, page):

        From = int(page) * PAGE_LIMIT

        sql = 'SELECT *,(SELECT username FROM user WHERE uid = contest.cuid) as username FROM contest ORDER BY contest.cid DESC LIMIT {} , {} '.format(
            From, PAGE_LIMIT + 1)

        print(sql)

        rs = FetchAll(sql)

        return rs
示例#8
0
    def getProblemList(self, cid):

        whereclause = ' cid = {} '.format(cid)
        ordclause = ' cpid '
        selectitem = ' cpid,pid '

        sql = getQueryDetailSQL('cproblem',
                                selectitem=selectitem,
                                whereclause=whereclause,
                                ordclause=ordclause)
        rs = FetchAll(sql)

        return rs
示例#9
0
    def getUserACSubmit(self, username):

        where = 'username = "******" and status LIKE "%Accept%"'.format(username)
        select = ' DISTINCT originOJ,originProb '
        sql = getQueryDetailSQL('status',
                                selectitem=select,
                                whereclause=where,
                                ordclause=' originOJ,originProb ')

        print('sql: ', sql)
        rs = FetchAll(sql)

        return rs
示例#10
0
    def getStauts(self, index, data, uid):
        # where clause

        whereclause = ''

        for key in data:
            if len(whereclause) != 0:
                whereclause = whereclause + ' and '
            whereclause = whereclause + key + ' LIKE "%' + data[key] + '%"'

        ordclause = 'originProb'

        if index == '%': index = '0'
        if index is None: index = '0'

        sql = getPageLimitSQL('problem', whereclause, ordclause, index, 21)

        print(sql)
        rs = FetchAll(sql)

        ac = list()

        tr = [0 for i in range(len(rs))]
        ac = [0 for i in range(len(rs))]
        if uid is None:
            pass
        else:
            '''
            for r in rs :
                x = CheckIfAccept(uid,r[0])
                ac.append(x)
            '''
            ac = [0 for i in range(len(rs))]
            for i in range(len(rs)):
                if uid is not None:
                    ac[i] = CheckIfAccept(uid, rs[i][0])[0]
                    if ac[i] == 1: tr[i] = 1
                    else: tr[i] = CheckIfTry(uid, rs[i][0])[0]

        print('rs size: ', len(rs))
        '''
        ac = [ x[0] for x in ac ]
        tr = [ x[0] for x in tr ]
        '''

        return rs, ac, tr
示例#11
0
def GetUserRank(username) :

    sql = rankSLQ+'WHERE uname = "{}";'.format(username)
    return FetchAll(sql)[0]
示例#12
0
def GetAuthorsRank(page,pagelimit) :

    sql = rankSLQ+'LIMIT {},{};'.format(pagelimit*page,pagelimit+1)
    return FetchAll(sql)
示例#13
0
def CountContestACNum(cid):

    sql = 'SELECT pid,COUNT(*) FROM status WHERE cid = {} and status LIKE "%accept%" GROUP BY pid;'.format(cid)
    return FetchAll(sql)
示例#14
0
def CountContestSubmitNum(cid) :

    sql = 'SELECT pid,COUNT(*) FROM status WHERE cid = {} GROUP BY pid;'.format(cid)
    return FetchAll(sql)