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,9 +268,13 @@ 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:
desc = desc.replace('"', "“")
return 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():
try:
current_app.logger.info("Start Item Report Generation")
with scheduler.app.app_context():
with scheduler.app.app_context():
try:
current_app.logger.info("Start Item Report Generation")
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,
@ -77,23 +79,25 @@ def gen_item_report():
)
new_report.save()
current_app.logger.info(f"Generated Item Report for {date}")
except Exception as e:
current_app.logger.critical(f"REPORT::ITEMS - {e}")
return
current_app.logger.info(f"Generated Item Report for {date}")
except Exception as e:
current_app.logger.critical(f"REPORT::ITEMS - {e}")
return
@scheduler.task("cron", id="gen_currency_report", hour=23, timezone="UTC")
def gen_currency_report():
try:
current_app.logger.info("Start Currency Report Generation")
with scheduler.app.app_context():
with scheduler.app.app_context():
try:
current_app.logger.info("Start Currency Report Generation")
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,
@ -119,23 +123,25 @@ def gen_currency_report():
)
new_report.save()
current_app.logger.info(f"Generated Currency Report for {date}")
except Exception as e:
current_app.logger.critical(f"REPORT::CURRENCY - {e}")
return
current_app.logger.info(f"Generated Currency Report for {date}")
except Exception as e:
current_app.logger.critical(f"REPORT::CURRENCY - {e}")
return
@scheduler.task("cron", id="gen_uscore_report", hour=23, timezone="UTC")
def gen_uscore_report():
try:
current_app.logger.info("Start U-Score Report Generation")
with scheduler.app.app_context():
with scheduler.app.app_context():
try:
current_app.logger.info("Start U-Score Report Generation")
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,
@ -161,7 +167,7 @@ def gen_uscore_report():
)
new_report.save()
current_app.logger.info(f"Generated U-Score Report for {date}")
except Exception as e:
current_app.logger.critical(f"REPORT::U-SCORE - {e}")
return
current_app.logger.info(f"Generated U-Score Report for {date}")
except Exception as e:
current_app.logger.critical(f"REPORT::U-SCORE - {e}")
return

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)