Merge branch 'main' into character-rescue

This commit is contained in:
Aaron Kimbre 2022-02-19 22:37:34 -06:00
commit 04f4e833a4
3 changed files with 42 additions and 23 deletions

View File

@ -268,7 +268,11 @@ def register_luclient_jinja_helpers(app):
'select description from Objects where id = ?',
[lot_id],
one=True
)[0]
)
if desc in ("", None):
desc = None
else:
desc = desc[0]
if desc in ("", None):
desc = None
if desc:

View File

@ -37,15 +37,17 @@ def uscore_by_date(date):
@scheduler.task("cron", id="gen_item_report", hour=23, timezone="UTC")
def gen_item_report():
with scheduler.app.app_context():
try:
current_app.logger.info("Start Item Report Generation")
with scheduler.app.app_context():
date = datetime.date.today().strftime('%Y-%m-%d')
report = Reports.query.filter(Reports.date==date).filter(Reports.report_type=="items").first()
# Only one report per day
if report != None:
current_app.logger.info(f"Item Report Already Generated for {date}")
return
char_xmls = CharacterXML.query.join(
CharacterInfo,
@ -85,15 +87,17 @@ def gen_item_report():
@scheduler.task("cron", id="gen_currency_report", hour=23, timezone="UTC")
def gen_currency_report():
with scheduler.app.app_context():
try:
current_app.logger.info("Start Currency Report Generation")
with scheduler.app.app_context():
date = datetime.date.today().strftime('%Y-%m-%d')
report = Reports.query.filter(Reports.date==date).filter(Reports.report_type=="currency").first()
# Only one report per day
if report != None:
current_app.logger.info(f"Currency Report Already Generated for {date}")
return
characters = CharacterXML.query.join(
CharacterInfo,
@ -127,15 +131,17 @@ def gen_currency_report():
@scheduler.task("cron", id="gen_uscore_report", hour=23, timezone="UTC")
def gen_uscore_report():
with scheduler.app.app_context():
try:
current_app.logger.info("Start U-Score Report Generation")
with scheduler.app.app_context():
date = datetime.date.today().strftime('%Y-%m-%d')
report = Reports.query.filter(Reports.date==date).filter(Reports.report_type=="uscore").first()
# Only one report per day
if report != None:
current_app.logger.info(f"U-Score Report Already Generated for {date}")
return
characters = CharacterXML.query.join(
CharacterInfo,

11
wsgi.py
View File

@ -13,4 +13,13 @@ def make_shell_context():
if __name__ == '__main__':
with app.app_context():
app.run(host='0.0.0.0')
else:
import logging
from logging.handlers import RotatingFileHandler
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
file_handler = RotatingFileHandler('nexus_dashboard.log', maxBytes=1024 * 1024 * 100, backupCount=20)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
file_handler.setFormatter(formatter)
app.logger.addHandler(file_handler)
app.logger.setLevel(gunicorn_logger.level)