refactor naming

This commit is contained in:
Beverly Nguyen
2025-01-23 11:53:27 -08:00
parent 8f30f9320a
commit cae2ec1a6d
3 changed files with 8 additions and 10 deletions

View File

@@ -4,6 +4,7 @@
let currentType = 'service'; let currentType = 'service';
const tableContainer = document.getElementById('activityContainer'); const tableContainer = document.getElementById('activityContainer');
const currentUserName = tableContainer.getAttribute('data-currentUserName'); const currentUserName = tableContainer.getAttribute('data-currentUserName');
const currentServiceId = tableContainer.getAttribute('data-currentServiceId');
const COLORS = { const COLORS = {
delivered: '#0076d6', delivered: '#0076d6',
failed: '#fa9441', failed: '#fa9441',
@@ -212,7 +213,7 @@
return; return;
} }
var url = type === 'service' ? `/daily_stats.json` : `/daily_stats_by_user.json`; var url = type === 'service' ? `/services/${currentServiceId}/daily-stats.json` : `/services/${currentServiceId}/daily-stats-by-user.json`;
return fetch(url) return fetch(url)
.then(response => { .then(response => {
if (!response.ok) { if (!response.ok) {

View File

@@ -76,25 +76,22 @@ def service_dashboard(service_id):
) )
@main.route("/daily_stats.json") @main.route("/services/<uuid:service_id>/daily-stats.json")
def get_daily_stats(): def get_daily_stats(service_id):
service_id = session.get("service_id")
date_range = get_stats_date_range() date_range = get_stats_date_range()
stats = service_api_client.get_service_notification_statistics_by_day( stats = service_api_client.get_service_notification_statistics_by_day(
service_id, start_date=date_range["start_date"], days=date_range["days"] service_id, start_date=date_range["start_date"], days=date_range["days"]
) )
return jsonify(stats) return jsonify(stats)
@main.route("/daily_stats_by_user.json") @main.route("/services/<uuid:service_id>/daily-stats-by-user.json")
def get_daily_stats_by_user(): def get_daily_stats_by_user(service_id):
service_id = session.get("service_id") service_id = session.get("service_id")
date_range = get_stats_date_range() date_range = get_stats_date_range()
user_id = current_user.id
stats = service_api_client.get_user_service_notification_statistics_by_day( stats = service_api_client.get_user_service_notification_statistics_by_day(
service_id, service_id,
user_id, user_id=current_user.id,
start_date=date_range["start_date"], start_date=date_range["start_date"],
days=date_range["days"], days=date_range["days"],
) )

View File

@@ -18,7 +18,7 @@
</div> </div>
</div> </div>
<div id="aria-live-account" class="usa-sr-only" aria-live="polite"></div> <div id="aria-live-account" class="usa-sr-only" aria-live="polite"></div>
<div class="table-container" id="activityContainer" data-currentUserName="{{ current_user.name }}"> <div class="table-container" id="activityContainer" data-currentUserName="{{ current_user.name }}" data-currentServiceId="{{current_service.id}}">
<div id="tableActivity" class="table-overflow-x-auto"> <div id="tableActivity" class="table-overflow-x-auto">
<h2 id="table-heading" class="margin-top-4 margin-bottom-1">Service activity</h2> <h2 id="table-heading" class="margin-top-4 margin-bottom-1">Service activity</h2>