Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uffd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca (strifel)
uffd
Commits
b99ec7b2
Commit
b99ec7b2
authored
3 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Improved performance of getuser api endpoint
parent
870c53cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uffd/api/views.py
+8
-4
8 additions, 4 deletions
uffd/api/views.py
with
8 additions
and
4 deletions
uffd/api/views.py
+
8
−
4
View file @
b99ec7b2
...
...
@@ -47,9 +47,11 @@ def getgroups():
abort
(
400
)
return
jsonify
([
generate_group_dict
(
group
)
for
group
in
groups
])
def
generate_user_dict
(
user
):
def
generate_user_dict
(
user
,
all_groups
=
None
):
if
all_groups
is
None
:
all_groups
=
user
.
groups
return
{
'
id
'
:
user
.
uid
,
'
loginname
'
:
user
.
loginname
,
'
email
'
:
user
.
mail
,
'
displayname
'
:
user
.
displayname
,
'
groups
'
:
[
group
.
name
for
group
in
user
.
group
s
]}
'
groups
'
:
[
group
.
name
for
group
in
all_groups
if
user
in
group
.
member
s
]}
@bp.route
(
'
/getusers
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@apikey_required
()
...
...
@@ -58,7 +60,6 @@ def getusers():
abort
(
400
)
key
=
(
list
(
request
.
values
.
keys
())
or
[
None
])[
0
]
values
=
request
.
values
.
getlist
(
key
)
Group
.
query
.
all
()
# Fill object cache for better preformance
if
key
is
None
:
users
=
User
.
query
.
all
()
elif
key
==
'
id
'
and
len
(
values
)
==
1
:
...
...
@@ -72,7 +73,10 @@ def getusers():
users
=
[]
if
group
is
None
else
group
.
members
else
:
abort
(
400
)
return
jsonify
([
generate_user_dict
(
user
)
for
user
in
users
])
all_groups
=
None
if
len
(
users
)
>
1
:
all_groups
=
Group
.
query
.
all
()
return
jsonify
([
generate_user_dict
(
user
,
all_groups
)
for
user
in
users
])
@bp.route
(
'
/checkpassword
'
,
methods
=
[
'
POST
'
])
@apikey_required
(
'
checkpassword
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment