async def get(self, *, uid_or_name: str = '', pid: str = '', tid: str = ''): query = await self.get_filter_query(uid_or_name, pid, tid) # TODO(iceboy): projection, pagination. rdocs = await record.get_all_multi( **query, get_hidden=self.has_priv(builtin.PRIV_VIEW_HIDDEN_RECORD)).sort([ ('_id', -1) ]).limit(50).to_list() # TODO(iceboy): projection. udict, pdict = await asyncio.gather( user.get_dict(rdoc['uid'] for rdoc in rdocs), problem.get_dict_multi_domain( (rdoc['domain_id'], rdoc['pid']) for rdoc in rdocs)) # statistics statistics = None if self.has_priv(builtin.PRIV_VIEW_JUDGE_STATISTICS): ts = calendar.timegm(datetime.datetime.utcnow().utctimetuple()) day_count, week_count, month_count, year_count, rcount = await asyncio.gather( record.get_count( objectid.ObjectId( struct.pack('>i', ts - 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count( objectid.ObjectId( struct.pack('>i', ts - 7 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count( objectid.ObjectId( struct.pack('>i', ts - 30 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count( objectid.ObjectId( struct.pack('>i', ts - int(365.2425 * 24 * 3600)) + struct.pack('b', -1) * 8)), record.get_count()) statistics = { 'day': day_count, 'week': week_count, 'month': month_count, 'year': year_count, 'total': rcount } self.render('record_main.html', rdocs=rdocs, udict=udict, pdict=pdict, statistics=statistics, filter_uid_or_name=uid_or_name, filter_pid=pid, filter_tid=tid, socket_url='/records-conn?' + urllib.parse.urlencode([('uid_or_name', uid_or_name), ('pid', pid), ('tid', tid)]))
async def get(self): # TODO(iceboy): projection, pagination. rdocs = await record.get_all_multi( get_hidden=self.has_priv(builtin.PRIV_VIEW_HIDDEN_RECORD)).sort([ ('_id', -1) ]).to_list(50) # TODO(iceboy): projection. udict, pdict = await asyncio.gather( user.get_dict(rdoc['uid'] for rdoc in rdocs), problem.get_dict_multi_domain( (rdoc['domain_id'], rdoc['pid']) for rdoc in rdocs)) # statistics statistics = None if self.has_priv(builtin.PRIV_VIEW_JUDGE_STATISTICS): ts = calendar.timegm(datetime.datetime.utcnow().utctimetuple()) day_count, week_count, month_count, year_count, rcount = await asyncio.gather( record.get_count( objectid.ObjectId( struct.pack('>i', ts - 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count( objectid.ObjectId( struct.pack('>i', ts - 7 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count( objectid.ObjectId( struct.pack('>i', ts - 30 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count( objectid.ObjectId( struct.pack('>i', ts - int(365.2425 * 24 * 3600)) + struct.pack('b', -1) * 8)), record.get_count()) statistics = { 'day': day_count, 'week': week_count, 'month': month_count, 'year': year_count, 'total': rcount } self.render('record_main.html', rdocs=rdocs, udict=udict, pdict=pdict, statistics=statistics)
async def get(self, *, start: str='', uid_or_name: str='', pid: str='', tid: str='', nopretest: str=None): if not self.has_perm(builtin.PERM_REJUDGE): start = '' if start: start = objectid.ObjectId(start) else: start = None ex_pretest = False if nopretest: if nopretest == 'on': ex_pretest = True query = await self.get_filter_query(uid_or_name, pid, tid, nopretest) # TODO(iceboy): projection, pagination. rdocs = await record.get_all_multi(**query, end_id=start, get_hidden=True).sort([('_id', -1)]).limit(50).to_list() # TODO(iceboy): projection. udict, pdict = await asyncio.gather( user.get_dict(rdoc['uid'] for rdoc in rdocs), problem.get_dict_multi_domain((rdoc['domain_id'], rdoc['pid']) for rdoc in rdocs)) # statistics statistics = None if self.has_priv(builtin.PRIV_VIEW_JUDGE_STATISTICS): ts = calendar.timegm(datetime.datetime.utcnow().utctimetuple()) day_count, week_count, month_count, year_count, rcount = await asyncio.gather( record.get_count(objectid.ObjectId( struct.pack('>i', ts - 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count(objectid.ObjectId( struct.pack('>i', ts - 7 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count(objectid.ObjectId( struct.pack('>i', ts - 30 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count(objectid.ObjectId( struct.pack('>i', ts - int(365.2425 * 24 * 3600)) + struct.pack('b', -1) * 8)), record.get_count()) statistics = {'day': day_count, 'week': week_count, 'month': month_count, 'year': year_count, 'total': rcount} url_prefix = '/d/{}'.format(urllib.parse.quote(self.domain_id)) query_string = urllib.parse.urlencode( [('uid_or_name', uid_or_name), ('pid', pid), ('tid', tid), ('nopretest', nopretest)]) #_logger.error(self.has_perm(builtin.PERM_REJUDGE)) self.render('record_main.html', rdocs=rdocs, udict=udict, pdict=pdict, statistics=statistics, filter_uid_or_name=uid_or_name, filter_pid=pid, filter_tid=tid, filter_nopretest=ex_pretest, socket_url=url_prefix + '/records-conn?' + query_string, # FIXME(twd2): magic query_string=query_string)
async def get(self, *, start: str='', uid_or_name: str='', pid: str='', tid: str=''): if not self.has_priv(builtin.PRIV_VIEW_JUDGE_STATISTICS): start = '' if start: try: start = objectid.ObjectId(start) except Exception: raise error.InvalidArgumentError('start') else: start = None query = await self.get_filter_query(uid_or_name, pid, tid) # TODO(iceboy): projection, pagination. rdocs = await record.get_all_multi(**query, end_id=start, get_hidden=self.has_priv(builtin.PRIV_VIEW_HIDDEN_RECORD)).sort([('_id', -1)]).limit(50).to_list() # TODO(iceboy): projection. udict, dudict, pdict = await asyncio.gather( user.get_dict(rdoc['uid'] for rdoc in rdocs), domain.get_dict_user_by_uid(domain_id=self.domain_id, uids=(rdoc['uid'] for rdoc in rdocs)), problem.get_dict_multi_domain((rdoc['domain_id'], rdoc['pid']) for rdoc in rdocs)) # statistics statistics = None if self.has_priv(builtin.PRIV_VIEW_JUDGE_STATISTICS): ts = calendar.timegm(datetime.datetime.utcnow().utctimetuple()) day_count, week_count, month_count, year_count, rcount = await asyncio.gather( record.get_count(objectid.ObjectId( struct.pack('>i', ts - 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count(objectid.ObjectId( struct.pack('>i', ts - 7 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count(objectid.ObjectId( struct.pack('>i', ts - 30 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count(objectid.ObjectId( struct.pack('>i', ts - int(365.2425 * 24 * 3600)) + struct.pack('b', -1) * 8)), record.get_count()) statistics = {'day': day_count, 'week': week_count, 'month': month_count, 'year': year_count, 'total': rcount} url_prefix = '/d/{}'.format(urllib.parse.quote(self.domain_id)) query_string = urllib.parse.urlencode( [('uid_or_name', uid_or_name), ('pid', pid), ('tid', tid)]) self.render( 'record_main.html', rdocs=rdocs, udict=udict, dudict=dudict, pdict=pdict, statistics=statistics, filter_uid_or_name=uid_or_name, filter_pid=pid, filter_tid=tid, socket_url=url_prefix + '/records-conn?' + query_string, # FIXME(twd2): magic query_string=query_string)
async def get(self, *, uid_or_name: str = '', pid: str = '', tid: str = ''): query = {} if uid_or_name: try: query['uid'] = int(uid_or_name) except ValueError: udoc = await user.get_by_uname(uid_or_name) if not udoc: raise error.UserNotFoundError(uid_or_name) from None query['uid'] = udoc['_id'] if pid: pid = document.convert_doc_id(pid) query['domain_id'] = self.domain_id query['pid'] = pid if tid: tid = document.convert_doc_id(tid) query['domain_id'] = self.domain_id query['tid'] = tid # TODO(iceboy): projection, pagination. rdocs = await record.get_all_multi( **query, get_hidden=self.has_priv(builtin.PRIV_VIEW_HIDDEN_RECORD)).sort([ ('_id', -1) ]).limit(50).to_list(None) # TODO(iceboy): projection. udict, pdict = await asyncio.gather( user.get_dict(rdoc['uid'] for rdoc in rdocs), problem.get_dict_multi_domain( (rdoc['domain_id'], rdoc['pid']) for rdoc in rdocs)) # statistics statistics = None if self.has_priv(builtin.PRIV_VIEW_JUDGE_STATISTICS): ts = calendar.timegm(datetime.datetime.utcnow().utctimetuple()) day_count, week_count, month_count, year_count, rcount = await asyncio.gather( record.get_count( objectid.ObjectId( struct.pack('>i', ts - 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count( objectid.ObjectId( struct.pack('>i', ts - 7 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count( objectid.ObjectId( struct.pack('>i', ts - 30 * 24 * 3600) + struct.pack('b', -1) * 8)), record.get_count( objectid.ObjectId( struct.pack('>i', ts - int(365.2425 * 24 * 3600)) + struct.pack('b', -1) * 8)), record.get_count()) statistics = { 'day': day_count, 'week': week_count, 'month': month_count, 'year': year_count, 'total': rcount } self.render('record_main.html', rdocs=rdocs, udict=udict, pdict=pdict, statistics=statistics, filter_uid_or_name=uid_or_name, filter_pid=pid, filter_tid=tid)