#NEWLINE# @ staff_member_required #NEWLINE# def finished_jobs( request , queue_index ) : #NEWLINE# #INDENT# queue_index = int ( queue_index ) #NEWLINE# queue = get_queue_by_index ( queue_index ) #NEWLINE# registry = FinishedJobRegistry ( queue . name , queue . connection ) #NEWLINE# items_per_page = 100 #NEWLINE# num_jobs = len ( registry ) #NEWLINE# page = int ( request . GET . get ( 'page' , 1 ) ) #NEWLINE# jobs = [ ] #NEWLINE# if ( num_jobs > 0 ) : #NEWLINE# #INDENT# last_page = int ( ceil ( ( num_jobs / items_per_page ) ) ) #NEWLINE# page_range = range ( 1 , ( last_page + 1 ) ) #NEWLINE# offset = ( items_per_page * ( page - 1 ) ) #NEWLINE# job_ids = registry . get_job_ids ( offset , items_per_page ) #NEWLINE# for job_id in job_ids : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# jobs . append ( Job . fetch ( job_id , connection = queue . connection ) ) #NEWLINE# #UNINDENT# except NoSuchJobError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# page_range = [ ] #NEWLINE# #UNINDENT# context_data = { #NEWLINE# #INDENT# 'queue' : queue , #NEWLINE# 'queue_index' : queue_index , #NEWLINE# 'jobs' : jobs , #NEWLINE# 'num_jobs' : num_jobs , #NEWLINE# 'page' : page , #NEWLINE# 'page_range' : page_range , #NEWLINE# 'job_status' : 'Finished' , #NEWLINE# #UNINDENT# } #NEWLINE# return render ( request , 'django_rq/jobs.html' , context_data )