mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 16:58:12 +00:00
Improve performance of job status updates through caching hashes
This commit is contained in:
@@ -55,6 +55,22 @@ def index():
|
||||
render_clients=render_clients(), preset_list=presets)
|
||||
|
||||
|
||||
@server.get('/api/jobs')
|
||||
def jobs_json():
|
||||
try:
|
||||
hash_token = request.args.get('token', None)
|
||||
all_jobs = [x.json() for x in RenderQueue.all_jobs()]
|
||||
job_cache_token = str(json.dumps(all_jobs).__hash__())
|
||||
|
||||
if hash_token and hash_token == job_cache_token:
|
||||
return [], 204 # no need to update
|
||||
else:
|
||||
return {'jobs': all_jobs, 'token': job_cache_token}
|
||||
except Exception as e:
|
||||
logger.exception(f"Exception fetching all_jobs_cached: {e}")
|
||||
return [], 500
|
||||
|
||||
|
||||
@server.route('/ui/job/<job_id>/full_details')
|
||||
def job_detail(job_id):
|
||||
found_job = RenderQueue.job_with_id(job_id)
|
||||
@@ -131,15 +147,6 @@ def get_job_file(job_id, filename):
|
||||
abort(404)
|
||||
|
||||
|
||||
@server.get('/api/jobs')
|
||||
def jobs_json():
|
||||
try:
|
||||
return [x.json() for x in RenderQueue.all_jobs()]
|
||||
except Exception as e:
|
||||
logger.exception(f"Exception fetching all_jobs: {e}")
|
||||
return [], 500
|
||||
|
||||
|
||||
@server.get('/api/jobs/<status_val>')
|
||||
def filtered_jobs_json(status_val):
|
||||
state = string_to_status(status_val)
|
||||
|
||||
Reference in New Issue
Block a user