Development
This commit is contained in:
parent
a4652866c3
commit
27eaea3d73
19 changed files with 602 additions and 427 deletions
28
docker/routlin-dash/app/api_apply_health.py
Normal file
28
docker/routlin-dash/app/api_apply_health.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from flask import Blueprint, request, jsonify
|
||||
from auth import require_level
|
||||
from config_utils import (
|
||||
_load_done_set, _is_locked, _lock_mtime,
|
||||
_seconds_until_next_run, _entry_ts_from_queue,
|
||||
)
|
||||
|
||||
bp = Blueprint('api_apply_health', __name__)
|
||||
|
||||
|
||||
@bp.route('/api/apply-health')
|
||||
@require_level('viewer')
|
||||
def apply_health():
|
||||
entry_uuid = request.args.get('uuid', '')
|
||||
if not entry_uuid:
|
||||
return jsonify({'status': 'unknown'})
|
||||
|
||||
if entry_uuid in _load_done_set():
|
||||
return jsonify({'status': 'complete'})
|
||||
|
||||
if _is_locked():
|
||||
mtime = _lock_mtime()
|
||||
entry_ts = _entry_ts_from_queue(entry_uuid)
|
||||
if mtime and entry_ts is not None and entry_ts < mtime:
|
||||
return jsonify({'status': 'running'})
|
||||
return jsonify({'status': 'pending', 'next_in': None})
|
||||
|
||||
return jsonify({'status': 'pending', 'next_in': _seconds_until_next_run()})
|
||||
Loading…
Add table
Add a link
Reference in a new issue