-
Notifications
You must be signed in to change notification settings - Fork 134
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
add support for merged datasets #1082
Conversation
Hey @ukanga I was testing out the the def get_last_submission_time(xforms):
values = [
x.last_submission_time
for x in xforms
if x.last_submission_time
]
if values:
return sorted(values, reverse=True)[0] Then inside the ...
validated_data['last_submission_time'] = get_last_submission_time(
validated_data['xforms']
) The above snippets seem to work for me but if there is a better implementation, that would be great. |
The idea was that it will be calculated on the fly. I will check on it. |
Cool, thanks @ukanga. I'll check it out UPDATE: works as expected |
docs/merged-datasets.rst
Outdated
Merged Datasets | ||
*************** | ||
|
||
This endpoint provides access to data from multiple forms Merged datasets should have the same functionality as the forms endpoint with the difference being: |
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.
add a period after "from" and before "Merged datasets"
docs/merged-datasets.rst
Outdated
^^^^^^^^^^ | ||
- ``name`` - Name or title of the merged dataset (required) | ||
- ``project`` - Project for the merged dataset (required) | ||
- ``xforms`` - list of forms to merge (required, at least 2 forms should be provided ) |
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.
should the "L" in "List" be capitalized? To make it consistent with the lines above, or should the others be lowercased (also, I know it's a nitpick sorry, there's an extra space before the parenthesis at the end of this line)
docs/merged-datasets.rst
Outdated
How data in parent forms differs from and affects the merged xform | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
A merged dataset combines data from multiple forms into one. It creates a new form structure from the intersection of the fields from the forms being merged. |
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 change the final "from" to "in" for clarity, so end of this line changes to "in the forms being merged."
CacheControlMixin, | ||
ETagsMixin, | ||
# pylint: disable=R0901 | ||
class ChartsViewSet(AnonymousUserPublicFormsMixin, AuthenticateHeaderMixin, |
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 don't get why to change this esp if it requires adding the pylint flag? I like the previous format
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.
Pylint R0901
has to do with "Too many ancestors".
The formatting at this time was under the mercy of yapf
command, I tend to take its recommendations. I should probably look into and check-in yapf's configuration.
@@ -171,7 +171,13 @@ def _get_instances(xform, start, end): | |||
if isinstance(end, datetime.datetime): | |||
kwargs.update({'date_created__lte': end}) | |||
|
|||
instances = xform.instances.filter(**kwargs) | |||
instances = xform.instances |
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.
this could go in an else
16e7429
to
776fdf9
Compare
I would like |
@ivermac I will add the field. |
776fdf9
to
800bf41
Compare
This PR now includes service integrations support for merged datasets. |
intersect = set([__ for (__, ___) in intersect]) | ||
|
||
merged_xform_dict['children'] = _get_elements(children, intersect) | ||
del merged_xform_dict['_xpath'] |
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.
@ukanga This could be re-written as
...
merged_xform_dict.get("_xpath") and merged_xform_dict.pop("_xpath")
On stage and locally, saving a merged dataset triggers the following error
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
…ractViewSet Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Ensure that: - `name` is a required field - `project` is a required field - `xforms` is a list of at least 2 xforms & should have unique elements Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
Signed-off-by: Njagi Mwaniki <[email protected]>
apply the MergedXForm permissions in roles Signed-off-by: Njagi Mwaniki <[email protected]>
Also, set sms_keyword to match the id_string, this affects sms_id_string Signed-off-by: Njagi Mwaniki <[email protected]>
It is messing up other tests and there is no point updating all fixtures to add the additional fields specific to this one test.
Added get_merged_xform_survey() function that uses the intersection of fields of xforms being merged to create a new survey object with only the intersecting fields.
PyxfformMarkdown is already mixed in TestBase
50ad2ae
to
d3534e3
Compare
Implements merged datasets as described in #1057