-
Notifications
You must be signed in to change notification settings - Fork 133
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
Include support for repeating sections for the tableau-onadata integration #1845
Conversation
9be5c9d
to
dee81d5
Compare
@WinnyTroy Data in nested groups is being downloaded to Tableau. |
@WinnyTroy I have tested different scenarios and the results are as follows;
|
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.
Can you add tests, please?
481755b
to
f3a4b47
Compare
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.
Generally looks good to me. I've added a few suggestions
index=index, | ||
close_tag=index_tags[1]) | ||
] | ||
if len(key.split('/')) > 1: |
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.
SInce we've referenced len(key.split('/'))
in line 70
and 64
, may be we want to set the call in a variable then call the variable on those lines.
except TypeError: | ||
xpaths = xpaths[0] + ('/').join(nested_key_diff) | ||
else: | ||
xpaths = xpaths + [nested_key.split('/')[1]] |
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.
SInce we've referenced nested_key.split('/')
in line 76 and 60, may be we want to set the call in a variable then call the variable on those lines.
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.
Alright, let me update this
xpaths = [ | ||
'{key}{open_tag}{index}{close_tag}'.format( | ||
key=key if len(key.split('/')) > 1 | ||
else nested_key.split('/')[0], | ||
open_tag=index_tags[0], | ||
index=index, | ||
close_tag=index_tags[1]) | ||
] |
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.
Not really sure what's going on here 😄
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've seen where it's been moved from 😄
a78b80c
to
5874767
Compare
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.
Getting close.
def unpack_data(key, value, data=None, xpaths=None): | ||
if isinstance(value, str) and data: | ||
choices = value.split(" ") | ||
for choice in choices: | ||
xpaths = f'{key}/{choice}' | ||
data[xpaths] = choice |
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.
Do we want to rename this function to something like update_data
since we are updating the data dictionary in the function?
xpaths = key + f'[{index}]/' + '/'.join(nested_key_diff) | ||
return xpaths | ||
|
||
def unpack_data(key, value, data=None, xpaths=None): |
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.
Please add a docstring for this function.... Finding it a bit hard to tell why xpaths
is an argument... In what scenario would someone pass xpaths ?
Is data supposed to be optional ? Seems like the function can't run without it ?
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.
Ah...changed those two items. Thanks for the catch
5874767
to
b7d97e6
Compare
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.
Getting close
xpaths = key + f'[{index}]/' + '/'.join(nested_key_diff) | ||
return xpaths | ||
|
||
def unpack_select_multiple_data(key, value, data): |
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.
Not really sure about the function name here since as mentioned in my previous comment, the main functionality, and correct me if I'm wrong, is to update the data
variable using choices values. How about we rename it to get_updated_data
and make ensure that data
is returned?
...
if isinstance(value, str) and data:
choices = value.split(" ")
for choice in choices:
xpaths = f'{key}/{choice}'
data[xpaths] = choice
return data
Then we can then assign the data
variable with result from get_updated_data
like the following:
...
if qstn_type == MULTIPLE_SELECT_TYPE:
data = get_updated_data(xpaths, nested_val, data)
7438753
to
78d16d8
Compare
Here is an overview of what got changed by this pull request: Complexity decreasing per file
==============================
+ onadata/apps/api/viewsets/open_data_viewset.py -1
See the complete overview on Codacy |
78d16d8
to
628dd53
Compare
Here is an overview of what got changed by this pull request: Complexity decreasing per file
==============================
+ onadata/apps/api/viewsets/open_data_viewset.py -1
Clones added
============
- onadata/apps/api/tests/viewsets/test_open_data_viewset.py 2
See the complete overview on Codacy |
Changes / Features implemented
Include support for nested repeats and nested groups for the tableau integration.
Steps taken to verify this change does what is intended
Side effects of implementing this change
None
Closes #
Resolves part of #1777