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

Updated stratifier behavior #129

Merged
merged 2 commits into from
Oct 17, 2024
Merged

Updated stratifier behavior #129

merged 2 commits into from
Oct 17, 2024

Conversation

dogversioning
Copy link
Contributor

  • Fixes stratifier to prevent returning all data
  • Adds a counts section to stratifier to match new vintage of chart data API

Copy link

github-actions bot commented Oct 16, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
699 664 95% 90% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/handlers/dashboard/get_chart_data.py 93% 🟢
TOTAL 93% 🟢

updated for commit: 39e236e by action🐍

@@ -61,29 +62,33 @@ def _build_query(query_params: dict, filters: list, path_params: dict) -> str:
select_str = f"{query_params['stratifier']}, {select_str}"
group_str = f"{query_params['stratifier']}, {group_str}"
columns.remove(query_params["stratifier"])
strat_str = f'AND {query_params["stratifier"]} IS NOT NULL '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing any quoting of these query params? We should probably be escaping them, then adding double quotes (or verifying that they match [a-zA-Z]+), yeah? That's what the ruff warning S608 is about, which is quieted below, yeah.

Does not need to block this PR, but feels important.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i was just thinking about how gross this approach to SQL construction was - I may make a ticket for this rather than deal with it as part of the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/handlers/dashboard/get_chart_data.py Outdated Show resolved Hide resolved
src/handlers/dashboard/get_chart_data.py Outdated Show resolved Hide resolved
Comment on lines +127 to +128
if "filter" in query_params and filters == []:
filters = [query_params["filter"]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the filters == [] check (which could be not filters I think)? Do we want to ignore a filter query entirely if multiValueQueryStringParameters is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in experimenting with this - I can't explictly say in cloudformation 'this parameter can be an array', so i'm not sure if it's going to be in queryStringParameters or multiValueQueryStringParameters in the AWS inbound event to the lambda. so I need to check both.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm not 100% sure of the expected usage here, but maybe combine the two arrays? It just felt odd to me that you'd ignore the filter query param in the case you get both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we got both (which I don't think should happen), queryStringParameters would have to be a subset of multiValueQueryStringParameters

tests/dashboard/test_get_chart_data.py Outdated Show resolved Hide resolved
tests/dashboard/test_get_chart_data.py Outdated Show resolved Hide resolved
@dogversioning dogversioning merged commit bd98255 into main Oct 17, 2024
2 checks passed
@dogversioning dogversioning deleted the mg/stratifier_update branch October 17, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants