04/27 Fixed some issues
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import csv
|
||||
import io
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from app.utils.time_utils import now_eastern
|
||||
from flask import (Blueprint, render_template, request,
|
||||
@@ -13,9 +14,12 @@ from app.models.issue import Issue
|
||||
from app.models.user import User
|
||||
from app.utils.decorators import supervisor_required
|
||||
from app.utils.scope import get_customer_scope
|
||||
from app.utils.audit import log_action, ACTION_EXPORT
|
||||
|
||||
bp = Blueprint('reports', __name__, url_prefix='/reports')
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _date_range():
|
||||
"""Parse ?start= and ?end= query params; default to last 30 days."""
|
||||
@@ -360,6 +364,17 @@ def facility_scorecard(facility_id):
|
||||
def export_inspections():
|
||||
start, end = _date_range()
|
||||
|
||||
logger.info(
|
||||
'REPORTS | export_inspections | user=%s | range=%s to %s',
|
||||
current_user.username,
|
||||
start.strftime('%Y-%m-%d'),
|
||||
end.strftime('%Y-%m-%d'),
|
||||
)
|
||||
log_action(
|
||||
ACTION_EXPORT, 'Inspection', None, 'CSV Export',
|
||||
f'range={start.strftime("%Y-%m-%d")} to {end.strftime("%Y-%m-%d")}',
|
||||
)
|
||||
|
||||
rows = db.session.query(
|
||||
Inspection.id,
|
||||
Inspection.inspection_date,
|
||||
@@ -414,6 +429,17 @@ def export_inspections():
|
||||
def export_issues():
|
||||
start, end = _date_range()
|
||||
|
||||
logger.info(
|
||||
'REPORTS | export_issues | user=%s | range=%s to %s',
|
||||
current_user.username,
|
||||
start.strftime('%Y-%m-%d'),
|
||||
end.strftime('%Y-%m-%d'),
|
||||
)
|
||||
log_action(
|
||||
ACTION_EXPORT, 'Issue', None, 'CSV Export',
|
||||
f'range={start.strftime("%Y-%m-%d")} to {end.strftime("%Y-%m-%d")}',
|
||||
)
|
||||
|
||||
rows = db.session.query(
|
||||
Issue.id,
|
||||
Issue.reported_at,
|
||||
|
||||
Reference in New Issue
Block a user