Commit 65660927 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added a user cache to search entry creation.

parent 4a5ac8b1
Pipeline #53083 failed with stages
in 17 minutes and 32 seconds
......@@ -32,6 +32,13 @@ path_analyzer = analyzer(
tokenizer=tokenizer('path_tokenizer', 'pattern', pattern='/'))
user_cache = dict()
"""
A cache for user popos used in the index. We will not retrieve names all the time.
This cache should be cleared, before larger re-index operations.
"""
class AlreadyExists(Exception): pass
......@@ -45,13 +52,16 @@ class User(InnerDoc):
@classmethod
def from_user_popo(cls, user):
self = cls(user_id=user.id)
self = user_cache.get(user.id, None)
if self is None:
self = cls(user_id=user.id)
if 'first_name' not in user:
user = coe_repo.User.from_user_id(user.id).to_popo()
if 'first_name' not in user:
user = coe_repo.User.from_user_id(user.id).to_popo()
name = '%s, %s' % (user['last_name'], user['first_name'])
self.name = name
name = '%s, %s' % (user['last_name'], user['first_name'])
self.name = name
user_cache[user.id] = self
return self
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment