Ensure that search doesn't make extra SQL lookups
Before this change, we were accessing the `.kind` on the repository object, which caused peewee to make an extra lookup for each result
This commit is contained in:
parent
9d97e053b3
commit
227aa8ab8c
2 changed files with 33 additions and 9 deletions
|
@ -3,6 +3,7 @@
|
|||
from endpoints.api import (ApiResource, parse_args, query_param, truthy_bool, nickname, resource,
|
||||
require_scope, path_param, internal_only, Unauthorized, InvalidRequest,
|
||||
show_if)
|
||||
from data.database import Repository
|
||||
from data import model
|
||||
from auth.permissions import (OrganizationMemberPermission, ReadRepositoryPermission,
|
||||
UserAdminPermission, AdministerOrganizationPermission,
|
||||
|
@ -266,7 +267,7 @@ def conduct_robot_search(username, query, results):
|
|||
|
||||
|
||||
def repo_result_view(repo, username, last_modified=None, stars=None, popularity=None):
|
||||
kind = 'application' if repo.kind.name == 'application' else 'repository'
|
||||
kind = 'application' if Repository.kind.get_name(repo.kind_id) == 'application' else 'repository'
|
||||
view = {
|
||||
'kind': kind,
|
||||
'title': 'app' if kind == 'application' else 'repo',
|
||||
|
|
Reference in a new issue