Skip to content

Commit

Permalink
clean: apply basic review
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-AntoineA committed Jul 8, 2024
1 parent ef265a0 commit 877f32a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 23 deletions.
5 changes: 0 additions & 5 deletions app/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,6 @@ def check_facets_are_valid(self):
raise ValueError(errors)
return self

def check_field_is_numeric(field):
"""
return error if field is non
"""

@model_validator(mode="after")
def check_charts_are_valid(self):
"""Check that the graph names are valid."""
Expand Down
7 changes: 3 additions & 4 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,14 @@ def search_get(
fields: GetSearchParamsTypes.fields = None,
sort_by: GetSearchParamsTypes.sort_by = None,
facets: GetSearchParamsTypes.facets = None,
charts: GetSearchParamsTypes.facets = None,
charts: GetSearchParamsTypes.charts = None,
index_id: GetSearchParamsTypes.index_id = None,
) -> SearchResponse:
# str to lists
langs_list = langs.split(",") if langs else ["en"]
fields_list = fields.split(",") if fields else None
facets_list = facets.split(",") if facets else None
charts = parse_charts_get(charts) if charts else None
print(charts)
charts_list = parse_charts_get(charts) if charts else None
# create SearchParameters object
try:
search_parameters = SearchParameters(
Expand All @@ -155,7 +154,7 @@ def search_get(
sort_by=sort_by,
facets=facets_list,
index_id=index_id,
charts=charts,
charts=charts_list,
)
return app_search.search(search_parameters)
except ValidationError as e:
Expand Down
9 changes: 2 additions & 7 deletions app/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def check_fields_are_numeric(
"""
* If field exists in global_config, check that it's numeric.
* If field looks like x.y and x.y does not exist in global config,
check that x is a n object field
check that x is an object field
"""
errors: list[str] = []
if values is None:
Expand All @@ -62,7 +62,6 @@ def check_fields_are_numeric(
for field_path in values:
field_path_list = field_path.split(".")
field_name = field_path_list[0]
print(len(field_path_list))
if field_name not in index_config.fields:
errors.append(f"Unknown field name: {field_name}")
elif len(field_path_list) == 1 and index_config.fields[field_name].type not in (
Expand All @@ -73,12 +72,8 @@ def check_fields_are_numeric(
):
errors.append(f"Non numeric field name: {field_name}")
elif (
len(field_path_list) == 2
len(field_path_list) >= 2
and index_config.fields[field_name].type != "object"
):
errors.append(f"Non object field name: {field_name}")
elif len(field_path_list) >= 3:
errors.append(
f"Only recursive fields with depth <= 2 are allowed, not: { field_name } (depth={len(field_path_list)})"
)
return errors
5 changes: 0 additions & 5 deletions frontend/src/mixins/search-ctl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,17 @@ import {
SearchaliciousHistoryInterface,
SearchaliciousHistoryMixin,
} from './history';
<<<<<<< HEAD
import {
SearchaliciousDistributionChart,
SearchaliciousScatterChart,
ChartSearchParam,
} from '../search-chart';
import {canResetSearch, isSearchChanged} from '../signals';
=======
import {SearchaliciousChart} from '../search-chart';
import {
canResetSearch,
isSearchChanged,
isSearchLoading,
searchResultDetail,
} from '../signals';
>>>>>>> 9fbec21b81a0c92185b29582556edfcb8461d897
import {SignalWatcher} from '@lit-labs/preact-signals';
import {isTheSameSearchName} from '../utils/search';

Expand Down
2 changes: 0 additions & 2 deletions frontend/src/search-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ export class SearchaliciousChart extends SearchaliciousResultCtlMixin(
export class SearchaliciousDistributionChart extends SearchaliciousChart {
static override styles = [WHITE_PANEL_STYLE];

// All these properties will change when vega logic
// will be moved in API.
@property()
field = '';

Expand Down

0 comments on commit 877f32a

Please sign in to comment.