-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35126 from dimagi/ze/trigger-es-index-geospatial-…
…enable Trigger Geopoint ES Index on Geospatial Feature Flag Enable
- Loading branch information
Showing
19 changed files
with
392 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from dimagi.utils.chunked import chunked | ||
|
||
from corehq.apps.es import case_search_adapter | ||
from corehq.apps.geospatial.es import case_query_for_missing_geopoint_val | ||
from corehq.form_processor.models import CommCareCase | ||
from corehq.util.log import with_progress_bar | ||
from corehq.apps.geospatial.const import DEFAULT_CHUNK_SIZE, DEFAULT_QUERY_LIMIT | ||
|
||
|
||
def process_batch( | ||
domain, | ||
geo_case_property, | ||
total_count, | ||
case_type=None, | ||
with_progress=False, | ||
offset=0, | ||
): | ||
sort_by = 'opened_on' if total_count > DEFAULT_QUERY_LIMIT else None | ||
query = case_query_for_missing_geopoint_val( | ||
domain, geo_case_property, case_type, offset=offset, sort_by=sort_by | ||
) | ||
case_ids = query.get_ids() | ||
_index_case_ids(domain, case_ids, with_progress) | ||
|
||
|
||
def _index_case_ids(domain, case_ids, with_progress): | ||
if with_progress: | ||
ids = with_progress_bar(case_ids) | ||
else: | ||
ids = case_ids | ||
for case_id_chunk in chunked(ids, DEFAULT_CHUNK_SIZE): | ||
case_chunk = CommCareCase.objects.get_cases(list(case_id_chunk), domain) | ||
case_search_adapter.bulk_index(case_chunk) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
corehq/apps/geospatial/templates/geospatial/partials/index_alert.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% load i18n %} | ||
|
||
{% if task_status.status == 'ERROR' %} | ||
<div class="alert alert-danger"> | ||
<p> | ||
{% if task_status.error_slug == 'TOO_MANY_CASES' %} | ||
{% blocktrans %} | ||
Existing cases in the domain were not processed to be available in Microplanning reports | ||
because there were too many to be processed. New or updated cases will still be available | ||
for use for Microplanning. Please reach out to support if you need support with existing cases. | ||
{% endblocktrans %} | ||
{% elif task_status.error_slug == 'CELERY' %} | ||
{% blocktrans %} | ||
Oops! Something went wrong while processing existing cases to be available in Microplanning | ||
reports. Please reach out to support. | ||
{% endblocktrans %} | ||
{% endif %} | ||
</p> | ||
</div> | ||
{% elif task_status.status == 'ACTIVE' %} | ||
<div class="alert alert-info"> | ||
<p> | ||
{% blocktrans %} | ||
Existing cases in the domain are being processed to be available in | ||
Microplanning reports. Please be patient. | ||
{% endblocktrans %} | ||
({{ task_status.progress}}%) | ||
</p> | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.