Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of validation of filters and raw fields. #18

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading