rounded_pk
This commit is contained in:
parent
73c0cbc0d2
commit
bcc5d8d2f3
2 changed files with 5 additions and 2 deletions
|
@ -293,6 +293,10 @@ class CustomLocation:
|
|||
y = round(self.y, 2)
|
||||
self.pk = 'c:%s:%s:%s' % (self.level.level_index, x, y)
|
||||
|
||||
@property
|
||||
def rounded_pk(self):
|
||||
return 'c:%s:%s:%s' % (self.level.level_index, self.x//5*5, self.y//5*5)
|
||||
|
||||
@property
|
||||
def serialized_geometry(self):
|
||||
return {
|
||||
|
|
|
@ -46,8 +46,7 @@ def get_position(request, parameters: LocateRequestSchema):
|
|||
location = Locator.load().locate(parameters.wifi_peers,
|
||||
permissions=AccessPermission.get_for_request(request))
|
||||
if location is not None:
|
||||
# todo: this will overload us probably, group these
|
||||
increment_cache_key('apistats__locate__%s' % location.pk)
|
||||
increment_cache_key('apistats__locate__%s' % location.rounded_pk)
|
||||
except ValidationError:
|
||||
# todo: validation error, seriously? this shouldn't happen anyways
|
||||
raise
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue