Skip to content

Commit

Permalink
Merge pull request #18 from aaronweeden/improve-validation-performance
Browse files Browse the repository at this point in the history
Improve performance of validation of filters and raw fields.
  • Loading branch information
aaronweeden authored May 7, 2024
2 parents ccb8458 + 1dfb3a5 commit 3354024
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Update tests and testing instructions ([\#14](https://github.com/ubccr/xdmod-data/pull/14)).
- Remove limit on number of results returned from `get_filter_values()` ([\#21](https://github.com/ubccr/xdmod-data/pull/21)).
- Add a "Feedback / Feature Requests" section to the README ([\#22](https://github.com/ubccr/xdmod-notebooks/pull/22)).
- Improve performance of validation of filters and raw fields ([\#18](https://github.com/ubccr/xdmod-data/pull/18)).

## v1.0.0 (2023-07-21)
- Initial release.
2 changes: 1 addition & 1 deletion xdmod_data/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = 'xdmod-data'
__version__ = '1.0.0'
__version__ = '1.0.1-beta.1'
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 3354024

Please sign in to comment.