-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Google Analytics runner - iterate over keys the Python 3 way #4538
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -164,7 +164,7 @@ def run_query(self, query, user): | |||||||
params = json_loads(query) | ||||||||
except: | ||||||||
params = parse_qs(urlparse(query).query, keep_blank_values=True) | ||||||||
for key in params.keys(): | ||||||||
for key in [*params]: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another option that would make fiddling with iterators (and the need to explain it) redundant is: query_string = parse_qs(urlparse(query).query, keep_blank_values=True)
params = {k.replace('-', '_'): ",".join(v) for k,v in query_string.items() } We'll still have to explain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this 👍 |
||||||||
params[key] = ",".join(params[key]) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
if "-" in key: | ||||||||
params[key.replace("-", "_")] = params.pop(key) | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the issue:
(this shows that the keys are iterated properly)
But, check the following:
So the issue is actually line 168 which applies
",".join
on any value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The real problem is line 170, which messes around with the
dict_keys
iterator, something that didn't happen in Python 2. Populating a new list of keys with[*params]
solves this.