Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
elasticsearch
Commits
abc0a8f42d8b
Commit
30d1caef
authored
Nov 17, 2020
by
Élodie Thiéblin
Browse files
[pagination] Number of items per page as query parameter
parent
c16822595d81
Pipeline
#27938
passed with stage
in 2 minutes and 22 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
cubicweb_elasticsearch/views.py
View file @
abc0a8f4
...
...
@@ -127,7 +127,8 @@ class ElasticSearchView(StartupView):
def
do_search
(
self
,
query_string
):
get_connection
(
self
.
_cw
.
vreg
.
config
)
facet_selections
=
{}
start
,
stop
=
0
,
10
items_per_page
=
int
(
self
.
_cw
.
form
.
get
(
"items_per_page"
,
10
))
start
,
stop
=
0
,
items_per_page
for
key
,
value
in
self
.
_cw
.
form
.
items
():
if
key
.
startswith
(
"es_"
):
if
isinstance
(
value
,
list
):
...
...
@@ -139,8 +140,8 @@ class ElasticSearchView(StartupView):
facet_selections
[
key
.
replace
(
"es_"
,
""
)]
=
value
if
key
==
"page"
:
try
:
start
=
(
max
(
int
(
value
)
-
1
,
0
))
*
10
stop
=
start
+
10
start
=
(
max
(
int
(
value
)
-
1
,
0
))
*
items_per_page
stop
=
start
+
items_per_page
except
ValueError
:
pass
search
=
self
.
customize_search
(
query_string
,
facet_selections
,
start
,
stop
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment