mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-11 07:03:47 -04:00
Updated new endpoint to use timezone
This commit is contained in:
@@ -80,8 +80,6 @@ def service_dashboard(service_id):
|
||||
@user_has_permissions()
|
||||
def get_daily_stats(service_id):
|
||||
date_range = get_stats_date_range()
|
||||
|
||||
# Get timezone from request (default to UTC if not provided)
|
||||
user_timezone = request.args.get("timezone", "UTC")
|
||||
|
||||
stats = service_api_client.get_service_notification_statistics_by_day(
|
||||
@@ -94,12 +92,15 @@ def get_daily_stats(service_id):
|
||||
@user_has_permissions()
|
||||
def get_daily_stats_by_user(service_id):
|
||||
service_id = session.get("service_id")
|
||||
user_timezone = request.args.get("timezone", "UTC")
|
||||
|
||||
date_range = get_stats_date_range()
|
||||
stats = service_api_client.get_user_service_notification_statistics_by_day(
|
||||
service_id,
|
||||
user_id=current_user.id,
|
||||
start_date=date_range["start_date"],
|
||||
days=date_range["days"],
|
||||
user_timezone=user_timezone,
|
||||
)
|
||||
return jsonify(stats)
|
||||
|
||||
|
||||
@@ -55,16 +55,15 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
)["data"]
|
||||
|
||||
def get_user_service_notification_statistics_by_day(
|
||||
self, service_id, user_id, start_date=None, days=None
|
||||
self, service_id, user_id, start_date=None, days=None, user_timezone="UTC"
|
||||
):
|
||||
if start_date is None:
|
||||
start_date = datetime.now(timezone.utc).strftime("%Y-%m-%d")
|
||||
|
||||
return self.get(
|
||||
"/service/{0}/statistics/user/{1}/{2}/{3}".format(
|
||||
service_id, user_id, start_date, days
|
||||
),
|
||||
)["data"]
|
||||
"/service/{0}/statistics/user/{1}/{2}/{3}?timezone={4}".format(
|
||||
service_id, user_id, start_date, days, user_timezone
|
||||
))["data"]
|
||||
|
||||
def get_services(self, params_dict=None):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user