Start on new interactive search
This commit is contained in:
parent
2ece1170a1
commit
951b0cbab8
7 changed files with 505 additions and 107 deletions
|
@ -679,6 +679,27 @@ def get_user_or_org_by_customer_id(customer_id):
|
|||
except User.DoesNotExist:
|
||||
return None
|
||||
|
||||
def get_matching_user_entities(entity_prefix, user):
|
||||
matching_user_orgs = ((User.username ** (entity_prefix + '%')) & (User.robot == False))
|
||||
matching_robots = ((User.username ** (user.username + '+%' + entity_prefix + '%')) &
|
||||
(User.robot == True))
|
||||
|
||||
query = (User.select()
|
||||
.where(matching_user_orgs | matching_robots)
|
||||
.limit(10))
|
||||
|
||||
return query
|
||||
|
||||
def get_matching_user_teams(team_prefix, user):
|
||||
query = (Team.select()
|
||||
.join(User)
|
||||
.switch(Team)
|
||||
.join(TeamMember)
|
||||
.where(TeamMember.user == user, Team.name ** (team_prefix + '%'))
|
||||
.limit(10))
|
||||
return query
|
||||
|
||||
|
||||
def get_matching_teams(team_prefix, organization):
|
||||
query = Team.select().where(Team.name ** (team_prefix + '%'),
|
||||
Team.organization == organization)
|
||||
|
@ -942,9 +963,17 @@ def get_matching_repositories(repo_term, username=None):
|
|||
search_clauses = (Repository.name ** ('%' + name_term + '%') &
|
||||
Namespace.username ** ('%' + namespace_term + '%'))
|
||||
|
||||
final = visible.where(search_clauses).limit(10)
|
||||
return list(final)
|
||||
return visible.where(search_clauses).limit(10)
|
||||
|
||||
def get_repository_pull_counts(repositories):
|
||||
repo_pull = LogEntryKind.get(name = 'pull_repo')
|
||||
|
||||
return (Repository.select(Repository.id, fn.Count(LogEntry.id))
|
||||
.where(Repository.id << [r.id for r in repositories])
|
||||
.join(LogEntry, JOIN_LEFT_OUTER)
|
||||
.where(LogEntry.kind == repo_pull)
|
||||
.group_by(LogEntry.repository)
|
||||
.tuples())
|
||||
|
||||
def change_password(user, new_password):
|
||||
if not validate_password(new_password):
|
||||
|
|
Reference in a new issue