renamed importlog* to job* -- in db, python and html

This commit is contained in:
2021-01-14 21:47:12 +11:00
parent 4df3274624
commit e884accd0a
5 changed files with 21 additions and 21 deletions

View File

@@ -20,7 +20,7 @@ import time
# Local Class imports # Local Class imports
################################################################################ ################################################################################
from settings import Settings from settings import Settings
from importlog import Importlog, Importlogline from job import Job, Joblog
class FileData(): class FileData():
def __init__(self): def __init__(self):

View File

@@ -8,20 +8,20 @@ from status import st, Status
from datetime import datetime, timedelta from datetime import datetime, timedelta
import pytz import pytz
class Importlogline(db.Model): class Joblog(db.Model):
id = db.Column(db.Integer, db.Sequence('ill_id_seq'), primary_key=True ) 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_date = db.Column(db.DateTime(timezone=True))
log = db.Column(db.String) log = db.Column(db.String)
def __repr__(self): 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 describing Action in the database, and via sqlalchemy, connected to the DB as well
################################################################################ ################################################################################
class Importlog(db.Model): class Job(db.Model):
id = db.Column(db.Integer, db.Sequence('importlog_id_seq'), primary_key=True ) id = db.Column(db.Integer, db.Sequence('joblog_id_seq'), primary_key=True )
start_time = db.Column(db.DateTime(timezone=True)) start_time = db.Column(db.DateTime(timezone=True))
last_update = db.Column(db.DateTime(timezone=True)) last_update = db.Column(db.DateTime(timezone=True))
state = db.Column(db.String) 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"]) @app.route("/jobs", methods=["GET"])
def imports(): def jobs():
page_title='Import actions' page_title='Job actions'
imports = Importlog.query.all() jobs = Job.query.all()
return render_template("imports.html", imports=imports, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() ) 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"]) @app.route("/job/<id>", methods=["GET"])
def importlog(id): def joblog(id):
page_title='Show Import Details' page_title='Show Job Details'
importlog = Importlog.query.get(id) joblog = Job.query.get(id)
logs=Importlogline.query.filter(Importlogline.import_id==id).all() logs=Joblog.query.filter(Joblog.job_id==id).all()
duration=(datetime.now(pytz.utc)-importlog.start_time) duration=(datetime.now(pytz.utc)-joblog.start_time)
duration= duration-timedelta(microseconds=duration.microseconds) 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 # This func creates a new filter in jinja2 to format the time from the db in a

View File

@@ -31,7 +31,7 @@ from settings import Settings
from files import Files from files import Files
from person import Person from person import Person
from refimg import Refimg from refimg import Refimg
from importlog import Importlog from job import Job
from ai import * from ai import *
####################################### CLASSES / DB model ####################################### ####################################### CLASSES / DB model #######################################