mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 11:51:05 -05:00
Currently requests to the API made from the admin app are going from PaaS admin app to the nginx router ELB, which then routes them back to the api app on PaaS. This makes sense for external requests, but for requests made from the admin app we could skip nginx and go directly to the api PaaS host, which should reduce load on the nginx instances and potentially reduce latency of the api requests. API apps on PaaS are checking the X-Custom-Forwarder header (which is set by nginx on proxy_pass requests) to only allow requests going through the proxy. This adds the custom header to the API client requests, so that they can pass that header check without going through nginx.
29 lines
922 B
Python
29 lines
922 B
Python
from app.notify_client import NotifyAdminAPIClient
|
|
|
|
|
|
class TemplateStatisticsApiClient(NotifyAdminAPIClient):
|
|
def __init__(self):
|
|
super().__init__("a" * 73, "b")
|
|
|
|
def get_template_statistics_for_service(self, service_id, limit_days=None):
|
|
params = {}
|
|
if limit_days is not None:
|
|
params['limit_days'] = limit_days
|
|
|
|
return self.get(
|
|
url='/service/{}/template-statistics'.format(service_id),
|
|
params=params
|
|
)['data']
|
|
|
|
def get_monthly_template_usage_for_service(self, service_id, year):
|
|
|
|
return self.get(
|
|
url='/service/{}/notifications/templates_usage/monthly?year={}'.format(service_id, year)
|
|
)['stats']
|
|
|
|
def get_template_statistics_for_template(self, service_id, template_id):
|
|
|
|
return self.get(
|
|
url='/service/{}/template-statistics/{}'.format(service_id, template_id)
|
|
)['data']
|