def get_application_monitor_data(request, pk):
"""
Returns API client usage data to be shown in the monitor page.
This view should return a JSON response with a 'data' field including a list of API usage event.
Each event should include a 'date' field with the timestamp as returned by Pythons Datetime.timestamp() object
(https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp) and with a 'service' property
with the service name (to which a request was forwarded).
"""
#application = get_object_or_404(ApiClient, pk=pk)
fake_data_points = list()
today = datetime.datetime.today()
services = get_available_services()
import random
N_FAKE_POINTS = 1000
DAYS_SPAN = 60
for i in range(0, N_FAKE_POINTS):
fake_data_points.append({
'date': (today - datetime.timedelta(minutes=random.randint(0, 60*24*DAYS_SPAN))).timestamp(),
'service': random.choice(services).name,
})
return JsonResponse({'data': fake_data_points})
评论列表
文章目录