def top_requesters(request): if request.user.is_superuser: return admin.top_requesters(request) key = 'TOPREQUESTERS_CACHED' # check cache data = cache.get(key) or [] def _top_requesters(request): def row_formatter(input): for cc in input: row = [] row.append('<a href="%s">%s</a>' % (reverse('requester_details', kwargs={'requester_id': cc[0]}), cc[1])) row.append( '<a href="https://www.mturk.com/mturk/searchbar?requesterId=%s" target="_mturk">%s</a> (<a href="http://feed.crowdsauced.com/r/req/%s">RSS</a>)' % (cc[0], cc[0], cc[0])) row.extend(cc[2:6]) yield row columns = (('string', 'Requester ID'), ('string', 'Requester'), ('number', '#Task'), ('number', '#HITs'), ('number', 'Rewards'), ('datetime', 'Last Posted On')) ctx = { 'data': row_formatter(data), 'columns': columns, 'title': 'Top-1000 Recent Requesters', } return direct_to_template(request, 'main/graphs/table.html', ctx) return _top_requesters(request)
def top_requesters(request): if request.user.is_superuser: return admin.top_requesters(request) # TODO: link ui choice here data = ToprequestersReport.get_report_data( ToprequestersReport.AVAILABLE) or [] def _top_requesters(request): def row_formatter(input): for cc in input: row = [] row.append('<a href="%s">%s</a>' % ( reverse('requester_details', kwargs={'requester_id': cc[0]}), cc[1])) row.append(('<a href="https://www.mturk.com/mturk/searchbar?' 'requesterId=%s" target="_mturk">%s</a> ' '(<a href="http://feed.crowdsauced.com/r/req/%s">RSS</a>)') % (cc[0], cc[0], cc[0])) row.extend(cc[2:6]) yield row columns = ( ('string', 'Requester ID'), ('string', 'Requester'), ('number', '#Task'), ('number', '#HITs'), ('number', 'Rewards'), ('datetime', 'Last Posted On') ) ctx = { 'data': row_formatter(data), 'columns': columns, 'title': 'Top-1000 Recent Requesters', } return direct_to_template(request, 'main/graphs/table.html', ctx) return _top_requesters(request)