renamed importlog* to job* -- in db, python and html
This commit is contained in:
2
files.py
2
files.py
@@ -20,7 +20,7 @@ import time
|
||||
# Local Class imports
|
||||
################################################################################
|
||||
from settings import Settings
|
||||
from importlog import Importlog, Importlogline
|
||||
from job import Job, Joblog
|
||||
|
||||
class FileData():
|
||||
def __init__(self):
|
||||
|
||||
@@ -8,20 +8,20 @@ from status import st, Status
|
||||
from datetime import datetime, timedelta
|
||||
import pytz
|
||||
|
||||
class Importlogline(db.Model):
|
||||
class Joblog(db.Model):
|
||||
id = db.Column(db.Integer, db.Sequence('ill_id_seq'), primary_key=True )
|
||||
import_id = db.Column(db.Integer, db.ForeignKey('import.id'), primary_key=True )
|
||||
job_id = db.Column(db.Integer, db.ForeignKey('job.id'), primary_key=True )
|
||||
log_date = db.Column(db.DateTime(timezone=True))
|
||||
log = db.Column(db.String)
|
||||
|
||||
def __repr__(self):
|
||||
return "<id: {}, import_id: {}, log: {}".format(self.id, self.import_id, self.log )
|
||||
return "<id: {}, job_id: {}, log: {}".format(self.id, self.job_id, self.log )
|
||||
|
||||
################################################################################
|
||||
# Class describing Action in the database, and via sqlalchemy, connected to the DB as well
|
||||
################################################################################
|
||||
class Importlog(db.Model):
|
||||
id = db.Column(db.Integer, db.Sequence('importlog_id_seq'), primary_key=True )
|
||||
class Job(db.Model):
|
||||
id = db.Column(db.Integer, db.Sequence('joblog_id_seq'), primary_key=True )
|
||||
start_time = db.Column(db.DateTime(timezone=True))
|
||||
last_update = db.Column(db.DateTime(timezone=True))
|
||||
state = db.Column(db.String)
|
||||
@@ -36,26 +36,26 @@ class Importlog(db.Model):
|
||||
|
||||
|
||||
################################################################################
|
||||
# /imports -> show current settings
|
||||
# /jobs -> show current settings
|
||||
################################################################################
|
||||
@app.route("/imports", methods=["GET"])
|
||||
def imports():
|
||||
page_title='Import actions'
|
||||
imports = Importlog.query.all()
|
||||
return render_template("imports.html", imports=imports, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
|
||||
@app.route("/jobs", methods=["GET"])
|
||||
def jobs():
|
||||
page_title='Job actions'
|
||||
jobs = Job.query.all()
|
||||
return render_template("jobs.html", jobs=jobs, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
|
||||
|
||||
|
||||
###############################################################################
|
||||
# /import/<id> -> GET -> shows status/history of imports
|
||||
# /job/<id> -> GET -> shows status/history of jobs
|
||||
################################################################################
|
||||
@app.route("/import/<id>", methods=["GET"])
|
||||
def importlog(id):
|
||||
page_title='Show Import Details'
|
||||
importlog = Importlog.query.get(id)
|
||||
logs=Importlogline.query.filter(Importlogline.import_id==id).all()
|
||||
duration=(datetime.now(pytz.utc)-importlog.start_time)
|
||||
@app.route("/job/<id>", methods=["GET"])
|
||||
def joblog(id):
|
||||
page_title='Show Job Details'
|
||||
joblog = Job.query.get(id)
|
||||
logs=Joblog.query.filter(Joblog.job_id==id).all()
|
||||
duration=(datetime.now(pytz.utc)-joblog.start_time)
|
||||
duration= duration-timedelta(microseconds=duration.microseconds)
|
||||
return render_template("importlog.html", imp=importlog, logs=logs, duration=duration, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
|
||||
return render_template("joblog.html", imp=joblog, logs=logs, duration=duration, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
|
||||
|
||||
###############################################################################
|
||||
# This func creates a new filter in jinja2 to format the time from the db in a
|
||||
2
main.py
2
main.py
@@ -31,7 +31,7 @@ from settings import Settings
|
||||
from files import Files
|
||||
from person import Person
|
||||
from refimg import Refimg
|
||||
from importlog import Importlog
|
||||
from job import Job
|
||||
from ai import *
|
||||
|
||||
####################################### CLASSES / DB model #######################################
|
||||
|
||||
Reference in New Issue
Block a user