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
bf2ace7f24fa
Commit
2307e068
authored
Feb 16, 2021
by
Arthur Lutz
Browse files
paint it black
parent
6683c63b10ca
Changes
7
Hide whitespace changes
Inline
Side-by-side
cubicweb_elasticsearch/hooks.py
View file @
bf2ace7f
...
...
@@ -42,7 +42,10 @@ class ContentUpdateIndexES(hook.Hook):
def
__call__
(
self
):
op_type
=
"delete"
if
self
.
event
==
"after_delete_entity"
else
"index"
IndexEsOperation
.
get_instance
(
self
.
_cw
).
add_data
(
{
"op_type"
:
op_type
,
"entity"
:
self
.
entity
,
}
{
"op_type"
:
op_type
,
"entity"
:
self
.
entity
,
}
)
...
...
@@ -61,7 +64,10 @@ class RelationsUpdateIndexES(hook.Hook):
):
if
entity_indexable
(
entity
):
IndexEsOperation
.
get_instance
(
self
.
_cw
).
add_data
(
{
"op_type"
:
"index"
,
"entity"
:
entity
,
}
{
"op_type"
:
"index"
,
"entity"
:
entity
,
}
)
...
...
cubicweb_elasticsearch/views.py
View file @
bf2ace7f
...
...
@@ -309,7 +309,12 @@ class ElasticSearchView(StartupView):
url_params
[
"page"
]
=
page
url
=
self
.
_cw
.
build_url
(
**
url_params
)
if
page
==
current_page
:
ul
(
t
.
li
(
t
.
a
(
t
.
b
(
page
),
href
=
xml_escape
(
url
)),
Class
=
"active"
,))
ul
(
t
.
li
(
t
.
a
(
t
.
b
(
page
),
href
=
xml_escape
(
url
)),
Class
=
"active"
,
)
)
else
:
ul
(
t
.
li
(
t
.
a
(
page
,
href
=
xml_escape
(
url
))))
return
url
...
...
setup.py
View file @
bf2ace7f
...
...
@@ -68,6 +68,10 @@ setup(
packages
=
find_packages
(
exclude
=
[
"test"
]),
install_requires
=
install_requires
,
include_package_data
=
True
,
entry_points
=
{
"cubicweb.cubes"
:
[
"elasticsearch=cubicweb_elasticsearch"
,]},
entry_points
=
{
"cubicweb.cubes"
:
[
"elasticsearch=cubicweb_elasticsearch"
,
]
},
zip_safe
=
False
,
)
test/test_elastic_search.py
View file @
bf2ace7f
...
...
@@ -20,7 +20,12 @@ from cubicweb_elasticsearch.es import indexable_types, fulltext_indexable_rql
class
ExportElasticSearchTC
(
testlib
.
AutoPopulateTest
):
# ignore ComputedRelations
ignored_relations
=
set
(
(
"narrower_concept"
,
"hidden_label"
,
"preferred_label"
,
"alternative_label"
,)
(
"narrower_concept"
,
"hidden_label"
,
"preferred_label"
,
"alternative_label"
,
)
)
def
setup_database
(
self
):
...
...
test/test_esqueue.py
View file @
bf2ace7f
...
...
@@ -33,7 +33,12 @@ class IndexHookTC(testlib.CubicWebTC):
ce
=
cnx
.
create_entity
p
=
ce
(
"Person"
,
age
=
12
,
name
=
u
"Jean"
)
cnx
.
commit
()
self
.
assertEqual
(
MockQueue
.
es_operations
,
[(
"index"
,
"Person"
,
p
.
eid
),
])
self
.
assertEqual
(
MockQueue
.
es_operations
,
[
(
"index"
,
"Person"
,
p
.
eid
),
],
)
def
test_esqueue_index_multiple
(
self
):
"""ensure queue gets filled with "index" operations"""
...
...
@@ -45,7 +50,10 @@ class IndexHookTC(testlib.CubicWebTC):
cnx
.
commit
()
self
.
assertCountEqual
(
MockQueue
.
es_operations
,
[(
"index"
,
"Person"
,
p
.
eid
),
(
"index"
,
"Person"
,
p2
.
eid
),
],
[
(
"index"
,
"Person"
,
p
.
eid
),
(
"index"
,
"Person"
,
p2
.
eid
),
],
)
def
test_esqueue_delete
(
self
):
...
...
@@ -61,7 +69,10 @@ class IndexHookTC(testlib.CubicWebTC):
cnx
.
commit
()
self
.
assertCountEqual
(
MockQueue
.
es_operations
,
[(
"delete"
,
"Person"
,
p
.
eid
),
(
"delete"
,
"Person"
,
p2
.
eid
),
],
[
(
"delete"
,
"Person"
,
p
.
eid
),
(
"delete"
,
"Person"
,
p2
.
eid
),
],
)
...
...
test/test_ifulltextadapter.py
View file @
bf2ace7f
...
...
@@ -31,7 +31,7 @@ class IFullTextIndexSerializableTC(testlib.CubicWebTC):
@
patch
(
"elasticsearch.client.Elasticsearch.index"
)
def
test_index_entity
(
self
,
index
,
exists
,
create
):
"""Only update indexable attributes while call entity.complete()
on IFullTextIndexSerializable.serialze()
on IFullTextIndexSerializable.serialze()
"""
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
with
self
.
temporary_appobjects
(
BlogFTIAdapter
,
BlogEntryFTIAdapter
):
...
...
tox.ini
View file @
bf2ace7f
...
...
@@ -57,7 +57,7 @@ basepython = python3
skip_install
=
true
deps
=
black
>=
19.10b0
commands
=
black
--target py36
.
commands
=
black .
[testenv:pypi-publish]
basepython
=
python3
...
...
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