Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Aug 15, 2024
1 parent 74efb4a commit 5566153
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
11 changes: 6 additions & 5 deletions share/search/index_strategy/trovesearch_flattery.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ def build(self) -> dict:
'date_by_propertypath': self._dates_by_propertypath(self._fullwalk),
},
}
logger.critical(json.dumps(_sourcedoc, indent=2))
return _sourcedoc

@functools.cached_property
Expand Down Expand Up @@ -604,7 +603,7 @@ def _valuesearch_date_aggs(self):
_aggs = {
'agg_value_at_propertypath': {
'aggs': {
'count_by_year': {
'agg_count_by_year': {
'date_histogram': {
'field': _field,
'calendar_interval': 'year',
Expand All @@ -629,7 +628,7 @@ def _valuesearch_response(
) -> ValuesearchResponse:
_iri_aggs = es8_response['aggregations'].get('in_nested_iri')
if _iri_aggs:
_buckets = _iri_aggs['value_at_propertypath']['agg_iri_values']['buckets']
_buckets = _iri_aggs['agg_value_at_propertypath']['agg_iri_values']['buckets']
_bucket_count = len(_buckets)
# WARNING: terribly inefficient pagination (part two)
_page_end_index = cursor.start_index + cursor.page_size
Expand All @@ -650,8 +649,10 @@ def _valuesearch_response(
)
else: # assume date
_year_buckets = (
es8_response['aggregations']['in_nested_date']
['value_at_propertypath']['count_by_year']['buckets']
es8_response['aggregations']
['agg_value_at_propertypath']
['agg_count_by_year']
['buckets']
)
return ValuesearchResponse(
search_result_page=[
Expand Down
3 changes: 2 additions & 1 deletion tests/share/bin/test_sharectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import pytest

from share.bin.util import execute_cmd
from share.test._testutil import patch_index_strategies
import share.version

from tests.share.search._testutil import patch_index_strategies


def run_sharectl(*args):
"""run sharectl, assert that it returned as expected, and return its stdout
Expand Down
11 changes: 0 additions & 11 deletions tests/_testutil.py → tests/share/search/_testutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
from share.search import index_strategy


def patch_feature_flag(*flag_names, up=True):
from share.models.feature_flag import FeatureFlag
_old_isup = FeatureFlag.objects.flag_is_up

def _patched_isup(flag_name):
if flag_name in flag_names:
return up
return _old_isup(flag_name)
return mock.patch.object(FeatureFlag.objects, 'flag_is_up', new=_patched_isup)


@contextlib.contextmanager
def patch_index_strategies(strategies: dict[str, index_strategy.IndexStrategy]):
index_strategy.all_index_strategies.cache_clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ def valuesearch_simple_cases(self) -> Iterator[tuple[dict[str, str], set[str]]]:
{'valueSearchPropertyPath': 'references'},
{BLARG.b, BLARG.c},
)
yield (
{'valueSearchPropertyPath': 'created'},
{'1999', '2012', '2024'},
)
# TODO: more

def valuesearch_complex_cases(self) -> Iterator[tuple[dict[str, str], set[str]]]:
Expand Down

0 comments on commit 5566153

Please sign in to comment.