Skip to content

Commit

Permalink
Improve performance of validation of filters and raw fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronweeden committed Dec 6, 2023
1 parent 736648a commit b09f2fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# xdmod-data Changelog

## Main development branch
- Improve performance of validation of filters and raw fields ([\#18](https://github.com/ubccr/xdmod-data/pull/18)).
- Update tests and testing instructions ([\#14](https://github.com/ubccr/xdmod-data/pull/14)).

## v1.0.0 (2023-07-21)
Expand Down
13 changes: 7 additions & 6 deletions xdmod_data/_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,14 @@ def __validate_filters(data_warehouse, descriptors, realm, filters):
if isinstance(filter_values, str):
filter_values = [filter_values]
result[dimension_id] = []
valid_filter_values = data_warehouse.get_filter_values(
realm,
dimension,
)
for filter_value in filter_values:
new_filter_value = __find_value_in_df(
'Filter value',
data_warehouse.get_filter_values(realm, dimension),
valid_filter_values,
filter_value,
)
result[dimension_id].append(new_filter_value)
Expand Down Expand Up @@ -214,12 +218,9 @@ def __find_str_in_sequence(value, sequence, label):
def __validate_raw_fields(data_warehouse, realm, fields):
try:
results = []
valid_raw_fields = data_warehouse.describe_raw_fields(realm)
for field in fields:
new_field = __find_value_in_df(
'Field',
data_warehouse.describe_raw_fields(realm),
field,
)
new_field = __find_value_in_df('Field', valid_raw_fields, field)
results.append(new_field)
return results
except TypeError:
Expand Down

0 comments on commit b09f2fc

Please sign in to comment.