Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
c7b1ade6
Commit
c7b1ade6
authored
7 years ago
by
Nathaniel Kofalt
Browse files
Options
Downloads
Patches
Plain Diff
Fix some null checks, and add a unique Queue.search filter
parent
c4bba02c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/dao/containerutil.py
+5
-3
5 additions, 3 deletions
api/dao/containerutil.py
api/handlers/containerhandler.py
+13
-2
13 additions, 2 deletions
api/handlers/containerhandler.py
with
18 additions
and
5 deletions
api/dao/containerutil.py
+
5
−
3
View file @
c7b1ade6
...
...
@@ -8,12 +8,14 @@ from ..auth import has_access
CONT_TYPES
=
[
'
acquisition
'
,
'
analysis
'
,
'
collection
'
,
'
group
'
,
'
project
'
,
'
session
'
]
SINGULAR_TO_PLURAL
=
{
'
acquisition
'
:
'
acquisitions
'
,
'
analysis
'
:
'
analyses
'
,
'
collection
'
:
'
collections
'
,
'
device
'
:
'
device
'
,
'
group
'
:
'
groups
'
,
'
job
'
:
'
job
'
,
'
project
'
:
'
projects
'
,
'
session
'
:
'
sessions
'
,
'
acquisition
'
:
'
acquisitions
'
,
'
collection
'
:
'
collections
'
,
'
analysis
'
:
'
analyses
'
,
}
PLURAL_TO_SINGULAR
=
{
p
:
s
for
s
,
p
in
SINGULAR_TO_PLURAL
.
iteritems
()}
...
...
This diff is collapsed.
Click to expand it.
api/handlers/containerhandler.py
+
13
−
2
View file @
c7b1ade6
...
...
@@ -162,10 +162,11 @@ class ContainerHandler(base.RequestHandler):
# Join from database if we haven't for this origin before
if
j_type
!=
'
unknown
'
and
result
[
'
join-origin
'
][
j_type
].
get
(
j_id
,
None
)
is
None
:
# Initial join
join_doc
=
config
.
db
[
j_type
+
'
s
'
].
find_one
({
'
_id
'
:
j_id_b
})
j_types
=
containerutil
.
pluralize
(
j_type
)
join_doc
=
config
.
db
[
j_types
].
find_one
({
'
_id
'
:
j_id_b
})
# Join in gear name on the job doc if requested
if
join_gear_name
and
j_type
==
'
job
'
:
if
join_doc
is
not
None
and
join_gear_name
and
j_type
==
'
job
'
:
gear_id
=
join_doc
[
'
gear_id
'
]
gear_name
=
None
...
...
@@ -267,6 +268,16 @@ class ContainerHandler(base.RequestHandler):
cont_array
=
[
containerutil
.
ContainerReference
(
'
analysis
'
,
cid
)
for
cid
in
id_array
]
results
+=
Queue
.
search
(
cont_array
,
states
=
states
,
tags
=
tags
)
# Stateful closure to remove search duplicates
# Eventually, this code should not call Queue.search and should instead do its own work.
def
match_ids
(
x
):
should_add
=
str
(
x
[
'
_id
'
])
in
match_ids
.
unique_job_ids
match_ids
.
unique_job_ids
.
add
(
str
(
x
[
'
_id
'
]))
return
should_add
match_ids
.
unique_job_ids
=
set
()
results
=
filter
(
lambda
x
:
match_ids
(
x
),
results
)
# Ensure job uniqueness
seen_jobs
=
[]
seen_gears
=
[]
...
...
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