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 report filtering related to system forms #31654

Merged
merged 7 commits into from
May 25, 2022
Merged

Conversation

snopoke
Copy link
Contributor

@snopoke snopoke commented May 20, 2022

Product Description

Changes to the way we filter forms by application and user.

User filter changes

Change made to allow 'system' forms to be displayed which don't usually have a user associated with them:

  • When no filters are applied
    • Previous behaviour
      • filter the data by all user IDs in the project (active and inactive).
    • New behaviour
      • do not filter by user ID at all.

App filter changes

  • Dropdown options for 'unknown forms'

    • Previous behaviour
      • Only include forms that were submitted from an application (have an app_id field
    • New behaviour
      • Include all 'unknown' forms including those that don't have an app_id field
  • When the default options are selected ("Show Forms in all Applications")

    • Previous behaviour
      • Don't apply app filtering at all. This would include forms that don't come from an app e.g. system forms
    • New behaviour
      • Filter out forms that do not have an app ID
  • Unknown user system form filter

    • Previous behaviour
      • If 'unknown users' was NOT selected as a filter option then filter out specific system forms
        • This would only filter on some system XMLNS
    • New behaviour
      • Removed completely - do not change XMLNS filtering based on user types

Spec: https://docs.google.com/document/d/1t97k35y9juT7Wl_suOiWi-NYP3cpiaV4hUmZ0j2e-e4/edit#heading=h.lqyt6iorkjwv
Jira: https://dimagi-dev.atlassian.net/browse/USH-1844

Technical Summary

The biggest change was to make the app / xml ES aggregation include forms with no app_id: 54c51aa

A few other filter changes.

Safety Assurance

Safety story

I consider this quite safe. It does alter a system report but only minor logic changes have been done.

Automated test coverage

None

QA Plan

Will be QA'd on staging.

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@snopoke snopoke added awaiting QA QA in progress. Do not merge product/all-users-all-environments Change impacts all users on all environments labels May 20, 2022
@snopoke snopoke marked this pull request as ready for review May 20, 2022 14:04
@snopoke snopoke changed the title Sk/system form filter improve filtering related to system forms May 20, 2022
@snopoke snopoke changed the title improve filtering related to system forms improve report filtering related to system forms May 20, 2022
@snopoke snopoke added QA Passed and removed awaiting QA QA in progress. Do not merge labels May 25, 2022
@snopoke snopoke merged commit e5c9d21 into master May 25, 2022
@snopoke snopoke deleted the sk/system-form-filter branch May 25, 2022 14:15
Copy link
Contributor

@esoergel esoergel left a comment

Choose a reason for hiding this comment

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

Very nice, I'm excited about these changes

assert re.match(r'\w+$', name), \
"Names must be valid python variable names, was {}".format(name)
self.name = name
self.body = {
"field": field,
"size": size if size is not None else SIZE_LIMIT,
}
if missing:
self.body["missing"] = missing
Copy link
Contributor

Choose a reason for hiding this comment

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


# filter results by app and xmlns if applicable
if FormsByApplicationFilter.has_selections(self.request):
form_values = list(self.all_relevant_forms.values())
if form_values:
query = query.OR(*[self._form_filter(f) for f in form_values])
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

aside: FormsByApplicationFilter.has_selections counts "Show Advanced Options" as a selection, which is a little unintuitive in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree but if you to select it and not change anything else then it does change the results to only include 'known forms'. I toyed with changing but the added complexity didn't seem worth it in the context of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/all-users-all-environments Change impacts all users on all environments QA Passed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants