From 5e3b073cde7e02436730178a7f0e4f60175e1b43 Mon Sep 17 00:00:00 2001 From: Hongwei Date: Wed, 6 Dec 2023 12:15:37 +0100 Subject: [PATCH] feature/added the lastEndpoint info on metric page - added the to_date to get_metric_last_endpoint --- apimanager/metrics/static/metrics/js/lastEndpointMetric.js | 6 ++---- apimanager/metrics/templates/metrics/api.html | 2 +- apimanager/metrics/views.py | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apimanager/metrics/static/metrics/js/lastEndpointMetric.js b/apimanager/metrics/static/metrics/js/lastEndpointMetric.js index 82c11f88..7e623329 100644 --- a/apimanager/metrics/static/metrics/js/lastEndpointMetric.js +++ b/apimanager/metrics/static/metrics/js/lastEndpointMetric.js @@ -6,12 +6,10 @@ function getMetricLastEndpoint(){ $.ajax({url: "/metrics/api/last-endpoint", success: function(result){ var content = "" +result['implemented_by_partial_function']+" took " - +result['duration']+"ms at " + +result['duration']+" ms at " +result['date']+" " +result['verb']+" " - + result['url'] - - +" ms."; + + result['url']; $("#last_endpoint").text(content); setTimeout(function(){getMetricLastEndpoint();}, 5000); // will call function to update time every 5 seconds }}); diff --git a/apimanager/metrics/templates/metrics/api.html b/apimanager/metrics/templates/metrics/api.html index 99184780..b335207c 100644 --- a/apimanager/metrics/templates/metrics/api.html +++ b/apimanager/metrics/templates/metrics/api.html @@ -14,7 +14,7 @@ {{ form.media }} {# Form required JS and CSS #} {% endblock %}

{% trans "API Metrics" %}

-
getBanks took 43ms at 2023-12-06T11:00:49Z GET /obp/v4.0.0/banks ms.
+

getBanks took 43ms at 2023-12-06T11:00:49Z GET /obp/v4.0.0/banks ms.

{% trans "Filter" %}

diff --git a/apimanager/metrics/views.py b/apimanager/metrics/views.py index cdacee80..fc4fa29f 100644 --- a/apimanager/metrics/views.py +++ b/apimanager/metrics/views.py @@ -203,7 +203,8 @@ def get_context_data(self, **kwargs): return context def get_metric_last_endpoint(request): - urlpath = "/management/metrics?limit=1" + to_date = datetime.datetime.now().strftime(settings.API_DATE_FORMAT_WITH_MILLISECONDS) + urlpath = "/management/metrics?limit=1&to_date="+to_date api = API(request.session.get('obp')) last_endpoint_metric={} try: