mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 13:28:25 -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()
|
@user_has_permissions()
|
||||||
def get_daily_stats(service_id):
|
def get_daily_stats(service_id):
|
||||||
date_range = get_stats_date_range()
|
date_range = get_stats_date_range()
|
||||||
|
|
||||||
# Get timezone from request (default to UTC if not provided)
|
|
||||||
user_timezone = request.args.get("timezone", "UTC")
|
user_timezone = request.args.get("timezone", "UTC")
|
||||||
|
|
||||||
stats = service_api_client.get_service_notification_statistics_by_day(
|
stats = service_api_client.get_service_notification_statistics_by_day(
|
||||||
@@ -94,12 +92,15 @@ def get_daily_stats(service_id):
|
|||||||
@user_has_permissions()
|
@user_has_permissions()
|
||||||
def get_daily_stats_by_user(service_id):
|
def get_daily_stats_by_user(service_id):
|
||||||
service_id = session.get("service_id")
|
service_id = session.get("service_id")
|
||||||
|
user_timezone = request.args.get("timezone", "UTC")
|
||||||
|
|
||||||
date_range = get_stats_date_range()
|
date_range = get_stats_date_range()
|
||||||
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=current_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"],
|
||||||
|
user_timezone=user_timezone,
|
||||||
)
|
)
|
||||||
return jsonify(stats)
|
return jsonify(stats)
|
||||||
|
|
||||||
|
|||||||
@@ -55,16 +55,15 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
|||||||
)["data"]
|
)["data"]
|
||||||
|
|
||||||
def get_user_service_notification_statistics_by_day(
|
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:
|
if start_date is None:
|
||||||
start_date = datetime.now(timezone.utc).strftime("%Y-%m-%d")
|
start_date = datetime.now(timezone.utc).strftime("%Y-%m-%d")
|
||||||
|
|
||||||
return self.get(
|
return self.get(
|
||||||
"/service/{0}/statistics/user/{1}/{2}/{3}".format(
|
"/service/{0}/statistics/user/{1}/{2}/{3}?timezone={4}".format(
|
||||||
service_id, user_id, start_date, days
|
service_id, user_id, start_date, days, user_timezone
|
||||||
),
|
))["data"]
|
||||||
)["data"]
|
|
||||||
|
|
||||||
def get_services(self, params_dict=None):
|
def get_services(self, params_dict=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user