Skip to content

Commit

Permalink
temporary ES template fixes, debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTango committed Oct 1, 2024
1 parent ba96074 commit 970c156
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion connector_elasticsearch/views/se_backend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<field name="inherit_id" ref="connector_search_engine.se_backend_form_view" />
<field name="arch" type="xml">
<group name="se-main" position="after">
<group name="elasticsearch" position="after">
<group
name="elasticsearch"
attrs="{'invisible': [('backend_type', '!=', 'elasticsearch')]}"
>
<field
name="es_server_host"
string="Host"
Expand Down
10 changes: 10 additions & 0 deletions connector_search_engine/models/se_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def _jobify_batch_sync(self, force_export: bool = False) -> None:
def _jobify_batch_recompute(self, force_export: bool = False) -> None:
self.ensure_one()
description = _("Prepare a batch recompute of index '%s'") % self.name
print(">>> run _jobify_batch_recompute")
# breakpoint()
self.with_delay(
description=description, identity_key=identity_exact
).batch_recompute(force_export)
Expand All @@ -231,9 +233,12 @@ def generate_batch_sync_per_index(self, domain: list | None = None) -> None:
index to sync. The sync will export the bindings marked as to_export.
and will delete the bindings marked as to_delete.
"""
print(">>>>> run generate_batch_sync_per_index")
if domain is None:
domain = []
for record in self.search(domain):
print(domain)
print(record)
record._jobify_batch_sync()

@api.model
Expand All @@ -244,9 +249,12 @@ def generate_batch_recompute_per_index(self, domain: list | None = None) -> None
index to recompute. The recompute process will recompute the bindings
marked as to_recompute.
"""
print(">>>>> run generate_batch_recompute_per_index")
if domain is None:
domain = []
for record in self.search(domain):
print(domain)
print(record)
record._jobify_batch_recompute()

def _get_domain_for_recomputing_binding(self, force_export: bool = False) -> list:
Expand All @@ -259,6 +267,7 @@ def _get_domain_for_recomputing_binding(self, force_export: bool = False) -> lis
def batch_recompute(self, force_export: bool = False) -> None:
"""Recompute all the bindings of the index marked as to_recompute."""
self.ensure_one()
print("###### >>> run batch_recompute")
domain = self._get_domain_for_recomputing_binding(force_export)
bindings = self.env["se.binding"].search(domain)
bindings_count = len(bindings)
Expand All @@ -272,6 +281,7 @@ def batch_recompute(self, force_export: bool = False) -> None:
"index_name": self.name,
}
batch.write({"state": "recomputing"})
print(description)
batch.with_delay(description=description).recompute_json()

def _get_domain_for_exporting_binding(self, force_export: bool = False):
Expand Down
16 changes: 16 additions & 0 deletions connector_search_engine/views/se_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
icon="fa-upload"
help="Force the export of all binding"
/>
<button
name="export_settings"
type="object"
string="Export settings"
icon="fa-upload"
help="Export settings"
groups="connector_search_engine.group_connector_search_engine_manager"
/>
<button
name="clear_index"
type="object"
Expand Down Expand Up @@ -200,6 +208,14 @@
icon="fa-upload"
type="object"
>Export all binding</a>
<a
name="export_settings"
role="menuitem"
class="dropdown-item"
help="Force the export of all binding"
icon="fa-upload"
type="object"
>Export settings</a>
<a
name="clear_index"
role="menuitem"
Expand Down

0 comments on commit 970c156

Please sign in to comment.