improve stats some more
This commit is contained in:
parent
8b9564a49f
commit
0c23e59342
2 changed files with 14 additions and 12 deletions
|
@ -48,7 +48,8 @@ def api_stats_clean_location_value(value):
|
||||||
if isinstance(value, str) and value.startswith('c:'):
|
if isinstance(value, str) and value.startswith('c:'):
|
||||||
value = value.split(':')
|
value = value.split(':')
|
||||||
value = 'c:%s:%d:%d' % (value[1], int(float(value[2]) / 3) * 3, int(float(value[3]) / 3) * 3)
|
value = 'c:%s:%d:%d' % (value[1], int(float(value[2]) / 3) * 3, int(float(value[3]) / 3) * 3)
|
||||||
return value
|
return (value, 'c:anywhere')
|
||||||
|
return (value, )
|
||||||
|
|
||||||
|
|
||||||
def api_stats(view_name):
|
def api_stats(view_name):
|
||||||
|
@ -58,7 +59,8 @@ def api_stats(view_name):
|
||||||
response = func(self, request, *args, **kwargs)
|
response = func(self, request, *args, **kwargs)
|
||||||
if response.status_code < 400 and kwargs:
|
if response.status_code < 400 and kwargs:
|
||||||
name, value = next(iter(kwargs.items()))
|
name, value = next(iter(kwargs.items()))
|
||||||
increment_cache_key('apistats__%s__%s__%s' % (view_name, name, api_stats_clean_location_value(value)))
|
for value in api_stats_clean_location_value(value):
|
||||||
|
increment_cache_key('apistats__%s__%s__%s' % (view_name, name, value))
|
||||||
return response
|
return response
|
||||||
return wrapped_func
|
return wrapped_func
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
|
@ -57,16 +57,16 @@ class RoutingViewSet(ViewSet):
|
||||||
'error': _('No route found.'),
|
'error': _('No route found.'),
|
||||||
})
|
})
|
||||||
|
|
||||||
increment_cache_key('apistats__route_tuple_%s_%s' % (
|
origin_values = api_stats_clean_location_value(form.cleaned_data['origin'].pk)
|
||||||
api_stats_clean_location_value(form.cleaned_data['origin'].pk),
|
destination_values = api_stats_clean_location_value(form.cleaned_data['destination'].pk)
|
||||||
api_stats_clean_location_value(form.cleaned_data['destination'].pk),
|
increment_cache_key('apistats__route')
|
||||||
))
|
for origin_value in origin_values:
|
||||||
increment_cache_key('apistats__route_origin_%s' % (
|
for destination_value in destination_values:
|
||||||
api_stats_clean_location_value(form.cleaned_data['origin'].pk),
|
increment_cache_key('apistats__route_tuple_%s_%s' % (origin_value, destination_value))
|
||||||
))
|
for value in origin_values:
|
||||||
increment_cache_key('apistats__route_destination_%s' % (
|
increment_cache_key('apistats__route_origin_%s' % value)
|
||||||
api_stats_clean_location_value(form.cleaned_data['destination'].pk),
|
for value in destination_values:
|
||||||
))
|
increment_cache_key('apistats__route_destination_%s' % value)
|
||||||
|
|
||||||
return Response({
|
return Response({
|
||||||
'request': {
|
'request': {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue