added plumbing for viewer to have a joblog search for the current file

This commit is contained in:
2022-02-05 23:23:10 +11:00
parent 10cbee450f
commit 83eff02910
3 changed files with 48 additions and 2 deletions

3
TODO
View File

@@ -2,6 +2,9 @@
* on viewer:
- allow face to be used to create person, add to existing person, and allow 'ignore', mark as 'not a face', etc
-> ignore/not a face/too young --> all need to go into DB so we can remember the 'override' when we re-ai-match
-> redraw 'ignore's as a greyed out box?
-> menu should only allow override IF we have put override on...
SO, override manual match, is awkward if somehow the file/face changes (e.g. we rescan a file for faces, do I delete override? if not and we rescan, there will he a new face id, how do I know which it connects with????)
- allow joblog search from the viewer for that file...
* should allow right-click from View menu (particularly useful on search) to show other files around this one by date (maybe that folder or something?)

37
job.py
View File

@@ -79,7 +79,6 @@ def GetNumActiveJobs():
################################################################################
def WakePAJobManager():
try:
print("Waking up PA Job Manager")
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT))
s.close()
@@ -175,7 +174,6 @@ def wakeup():
@app.route("/stale_job/<id>", methods=["POST"])
@login_required
def stale_job(id):
print( f"Handle Stale Job#{id} -> {request.form['action']} it")
job=Job.query.get(id)
now=datetime.now(pytz.utc)
db.session.add(job)
@@ -199,6 +197,8 @@ def stale_job(id):
WakePAJobManager()
return redirect("/jobs")
################################################################################
# list jobs that are maked stale
################################################################################
@app.route("/stale_jobs", methods=["GET"])
@login_required
@@ -207,6 +207,39 @@ def stale_jobs():
jobs = Job.query.filter(Job.pa_job_state=='Stale').order_by(Job.id.desc()).all()
return render_template("jobs.html", jobs=jobs, page_title=page_title)
################################################################################
# retrieve any log entries across ALL jobs that relate to this entry
# used in viewer on button click
################################################################################
@app.route("/joblog_search", methods=["POST"])
@login_required
def joblog_search():
eid=request.form['eid']
ent_cursor=db.engine.execute( f"select name from entry where id = {eid}" )
for ent in ent_cursor:
jobs_cursor=db.engine.execute( f"select l.log, j.id, j.name, j.state, j.last_update from joblog l, job j where l.job_id = j.id and l.log ilike '%%{ent[0]}%%' ")
# turn DB output into json and return it to the f/e
ret='[ '
first_job=1
last_job_id = -1
for j in jobs_cursor:
if not first_job:
ret +=", "
ret+= '{'
ret+= f'"id":"{j.id}", '
ret+= f'"name":"{j.name}", '
ret+= f'"finished":"{j.last_update}", '
ret+= f'"status":"{j.state}", '
ret+= f'"log": "{j.log}"'
ret+= '}'
first_job=0
ret+= ' ]'
return ret
###############################################################################
# This func creates a new filter in jinja2 to format the time from the db in a
# way that is more readable (converted to local tz too)

View File

@@ -75,6 +75,16 @@
return s
}
function JoblogSearch()
{
data="eid="+current
$.ajax({ type: 'POST', data: data, url: '/joblog_search', success: function(res) {
data = JSON.parse(res)
console.log(data)
}
})
}
function CallViewListRoute(dir)
{
data="eids="+$("#eids").val()