Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-django-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-django-backend
Commits
a0b5c8c3
"include/linkahead/utility.h" did not exist on "28e440ba8ccf94c9b994f8c3ba99ff0fb1c597ef"
Verified
Commit
a0b5c8c3
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: sorting
parent
c48d25cf
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
djaosdb/caosdb_client.py
+4
-1
4 additions, 1 deletion
djaosdb/caosdb_client.py
with
4 additions
and
1 deletion
djaosdb/caosdb_client.py
+
4
−
1
View file @
a0b5c8c3
...
@@ -34,6 +34,9 @@ class CountResult(Result):
...
@@ -34,6 +34,9 @@ class CountResult(Result):
def
__iter__
(
self
):
def
__iter__
(
self
):
return
iter
(
self
.
_results
)
return
iter
(
self
.
_results
)
def
_sort_key
(
x
,
field
):
return
x
[
field
]
or
""
class
FindResult
(
Result
):
class
FindResult
(
Result
):
def
__init__
(
self
,
rows
,
columns
,
sort
=
None
,
limit
=
None
,
skip
=
None
):
def
__init__
(
self
,
rows
,
columns
,
sort
=
None
,
limit
=
None
,
skip
=
None
):
...
@@ -47,7 +50,7 @@ class FindResult(Result):
...
@@ -47,7 +50,7 @@ class FindResult(Result):
if
columns
is
not
None
:
if
columns
is
not
None
:
if
sort
:
if
sort
:
named_columns
=
[
dict
(
zip
(
columns
,
row
))
for
row
in
rows
]
named_columns
=
[
dict
(
zip
(
columns
,
row
))
for
row
in
rows
]
named_columns
.
sort
(
key
=
lambda
x
:
x
[
sort
[
0
][
0
]
]
,
reverse
=
sort
[
0
][
1
]
<
0
)
named_columns
.
sort
(
key
=
lambda
x
:
_sort_key
(
x
,
sort
[
0
][
0
]
)
,
reverse
=
sort
[
0
][
1
]
<
0
)
self
.
_results
=
named_columns
[
skip
:
upper
]
self
.
_results
=
named_columns
[
skip
:
upper
]
else
:
else
:
self
.
_results
=
[]
self
.
_results
=
[]
...
...
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