mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
Add /apps/{appid}/latestjob route that redirects to the latest job
This commit is contained in:
parent
54c99f958a
commit
f08af652ee
1 changed files with 20 additions and 0 deletions
20
run.py
20
run.py
|
@ -1015,6 +1015,26 @@ async def html_app(request, app_name):
|
||||||
return {"app": app[0], 'relative_path_to_root': '../../', 'path': request.path}
|
return {"app": app[0], 'relative_path_to_root': '../../', 'path': request.path}
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/apps/<app_name>/latestjob')
|
||||||
|
async def html_app_latestjob(request, app_name):
|
||||||
|
_app = Repo.select().where(Repo.name == app_name)
|
||||||
|
|
||||||
|
if _app.count() == 0:
|
||||||
|
raise NotFound()
|
||||||
|
|
||||||
|
jobs = Job.select(fn.MAX(Job.id)).where(Job.url_or_path == _app[0].url, Job.state != 'scheduled')
|
||||||
|
|
||||||
|
if jobs.count() == 0:
|
||||||
|
jobs = Job.select(fn.MAX(Job.id)).where(Job.url_or_path == _app[0].url)
|
||||||
|
|
||||||
|
if jobs.count() == 0:
|
||||||
|
raise NotFound()
|
||||||
|
|
||||||
|
job_url = app.config.BASE_URL + app.url_for("html_job", job_id=jobs[0].id)
|
||||||
|
|
||||||
|
return response.redirect(job_url)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@jinja.template('index.html')
|
@jinja.template('index.html')
|
||||||
async def html_index(request):
|
async def html_index(request):
|
||||||
|
|
Loading…
Add table
Reference in a new issue