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
002b8736
Commit
002b8736
authored
9 years ago
by
Gunnar Schaefer
Browse files
Options
Downloads
Patches
Plain Diff
update all projections and do some cleanup
parent
5d198536
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
collections_.py
+3
-3
3 additions, 3 deletions
collections_.py
containers.py
+6
-12
6 additions, 12 deletions
containers.py
projects.py
+1
-1
1 addition, 1 deletion
projects.py
util.py
+2
-1
2 additions, 1 deletion
util.py
with
12 additions
and
17 deletions
collections_.py
+
3
−
3
View file @
002b8736
...
...
@@ -198,7 +198,7 @@ class Collections(containers.ContainerList):
def
get
(
self
):
"""
Return the list of Collections.
"""
query
=
{
'
curator_id
'
:
self
.
request
.
get
(
'
curator
'
)}
if
self
.
request
.
get
(
'
curator
'
)
else
{}
projection
=
{
'
curator_id
'
:
1
,
'
name
'
:
1
,
'
notes
'
:
1
}
projection
=
{
'
curator_id
'
:
1
,
'
name
'
:
1
,
'
notes
'
:
1
,
'
timestamp
'
:
1
,
'
timezone
'
:
1
}
collections
=
self
.
_get
(
query
,
projection
,
self
.
request
.
get
(
'
admin
'
).
lower
()
in
(
'
1
'
,
'
true
'
))
for
coll
in
collections
:
coll
[
'
_id
'
]
=
str
(
coll
[
'
_id
'
])
...
...
@@ -296,7 +296,7 @@ class CollectionSessions(sessions.Sessions):
{
'
$group
'
:
{
'
_id
'
:
'
$session
'
}},
])
query
=
{
'
_id
'
:
{
'
$in
'
:
[
ar
[
'
_id
'
]
for
ar
in
agg_res
]}}
projection
=
{
'
label
'
:
1
,
'
subject.code
'
:
1
,
'
notes
'
:
1
}
projection
=
{
'
label
'
:
1
,
'
subject.code
'
:
1
,
'
notes
'
:
1
,
'
timestamp
'
:
1
,
'
timezone
'
:
1
}
projection
[
'
permissions
'
]
=
{
'
$elemMatch
'
:
{
'
_id
'
:
self
.
uid
,
'
site
'
:
self
.
source_site
}}
sessions
=
list
(
self
.
dbc
.
find
(
query
,
projection
))
for
sess
in
sessions
:
...
...
@@ -333,7 +333,7 @@ class CollectionAcquisitions(acquisitions.Acquisitions):
query
[
'
session
'
]
=
bson
.
ObjectId
(
sid
)
elif
sid
!=
''
:
self
.
abort
(
400
,
sid
+
'
is not a valid ObjectId
'
)
projection
=
{
'
label
'
:
1
,
'
description
'
:
1
,
'
types
'
:
1
,
'
notes
'
:
1
}
projection
=
{
'
label
'
:
1
,
'
description
'
:
1
,
'
types
'
:
1
,
'
notes
'
:
1
,
'
timestamp
'
:
1
,
'
timezone
'
:
1
}
projection
[
'
permissions
'
]
=
{
'
$elemMatch
'
:
{
'
_id
'
:
self
.
uid
,
'
site
'
:
self
.
source_site
}}
acquisitions
=
list
(
self
.
dbc
.
find
(
query
,
projection
))
for
acq
in
acquisitions
:
...
...
This diff is collapsed.
Click to expand it.
containers.py
+
6
−
12
View file @
002b8736
...
...
@@ -5,10 +5,10 @@ log = logging.getLogger('scitran.api')
import
os
import
json
import
pytz
import
hashlib
import
jsonschema
import
bson.json_util
import
pytz
import
tempdir
as
tempfile
...
...
@@ -111,17 +111,11 @@ FILE_DOWNLOAD_SCHEMA = {
}
def
fixup_timestamps
(
item
):
if
'
timestamp
'
in
item
:
if
'
timezone
'
in
item
:
item_timezone
=
pytz
.
timezone
(
item
[
'
timezone
'
])
else
:
item_timezone
=
pytz
.
timezone
(
'
UTC
'
)
timestamp
=
item_timezone
.
localize
(
item
[
'
timestamp
'
])
item
[
'
timestamp
'
]
=
timestamp
.
isoformat
()
item
[
'
timezone
'
]
=
item_timezone
.
zone
def
fixup_timestamps
(
container
):
if
'
timestamp
'
in
container
:
container_timezone
=
pytz
.
timezone
(
container
.
get
(
'
timezone
'
,
None
)
or
'
UTC
'
)
container
[
'
timestamp
'
]
=
container_timezone
.
localize
(
container
[
'
timestamp
'
]).
isoformat
()
container
[
'
timezone
'
]
=
container_timezone
.
zone
class
ContainerList
(
base
.
RequestHandler
):
...
...
This diff is collapsed.
Click to expand it.
projects.py
+
1
−
1
View file @
002b8736
...
...
@@ -113,7 +113,7 @@ class Projects(containers.ContainerList):
def
get
(
self
):
"""
Return the User
'
s list of Projects.
"""
query
=
{
'
group_id
'
:
self
.
request
.
get
(
'
group
'
)}
if
self
.
request
.
get
(
'
group
'
)
else
{}
projection
=
{
'
group_id
'
:
1
,
'
name
'
:
1
,
'
notes
'
:
1
}
projection
=
{
'
group_id
'
:
1
,
'
name
'
:
1
,
'
notes
'
:
1
,
'
timestamp
'
:
1
,
'
timezone
'
:
1
}
projects
=
self
.
_get
(
query
,
projection
,
self
.
request
.
get
(
'
admin
'
).
lower
()
in
(
'
1
'
,
'
true
'
))
if
self
.
debug
:
for
proj
in
projects
:
...
...
This diff is collapsed.
Click to expand it.
util.py
+
2
−
1
View file @
002b8736
...
...
@@ -146,11 +146,12 @@ def _update_db(db, dataset):
fields
=
[],
)
if
dataset
.
nims_timestamp
:
db
.
projects
.
update
({
'
_id
'
:
project
[
'
_id
'
]},
{
'
$max
'
:
dict
(
timestamp
=
dataset
.
nims_timestamp
)})
db
.
projects
.
update
({
'
_id
'
:
project
[
'
_id
'
]},
{
'
$max
'
:
dict
(
timestamp
=
dataset
.
nims_timestamp
)
,
'
$set
'
:
dict
(
timezone
=
dataset
.
nims_timezone
)
})
db
.
sessions
.
update
({
'
_id
'
:
session
[
'
_id
'
]},
{
'
$min
'
:
dict
(
timestamp
=
dataset
.
nims_timestamp
),
'
$set
'
:
dict
(
timezone
=
dataset
.
nims_timezone
)})
# create a job, if necessary
return
acquisition
[
'
_id
'
]
# TODO: create job should be use-able from bootstrap.py with only database information
def
create_job
(
dbc
,
dataset
):
db
=
dbc
.
database
...
...
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