Skip to content

Commit

Permalink
fix: fix checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-AntoineA committed Jun 24, 2024
1 parent 91d3f72 commit 5dea4e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ class SearchParameters(BaseModel):
list[str] | None,
Query(
description="""Name of vega representations to return in the response.
If None (default) no charts are returrned."""
)
If None (default) no charts are returned."""
),
] = None
sort_params: Annotated[
JSONType | None,
Expand Down
14 changes: 9 additions & 5 deletions app/charts.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from ._types import SuccessSearchResponse
from ._types import ChartsInfos, SuccessSearchResponse


def build_charts(
search_result: SuccessSearchResponse,
charts_names: list[str] | None,
) -> str:
charts = {}
if charts_names is None:
) -> ChartsInfos:
charts: ChartsInfos = {}
aggregations = search_result.aggregations

if charts_names is None or aggregations is None:
return charts

for chart_name in charts_names:
buckets = search_result.aggregations[chart_name]["buckets"]
agg_data = aggregations.get(chart_name, {})

buckets = agg_data.get("buckets", []) if agg_data else []

# Filter unknown values
values = [
Expand Down
2 changes: 1 addition & 1 deletion app/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def parse_sort_by_script(


def create_aggregation_clauses(
config: IndexConfig, fields: list[str] | None
config: IndexConfig, fields: set[str] | list[str] | None
) -> dict[str, Agg]:
"""Create term bucket aggregation clauses
for all fields corresponding to facets,
Expand Down

0 comments on commit 5dea4e5

Please sign in to comment.