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
Update Case Activity Report to Account for Shared Cases #34464
Conversation
Had a pass at the code; looks good, but I'll wait till QA is done in case there's some changes that needs to be made. |
@@ -334,15 +336,46 @@ def make_column(title, help_text, num_days): | |||
def selected_users(self): | |||
return _get_selected_users(self.domain, self.request) | |||
|
|||
@property | |||
def has_group_filters(self): |
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.
nit: should we use "case_group" instead of group unless specifically referring to groups?
It does seem to get confusing at times if we use only "group" for case group and groups in HQ.
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 can see how this might get mistaken for the Group
Django model. I like your suggestion of case_group
. I'll change this out.
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.
return format_html(_( | ||
"Note that when viewing this report by group it will only include " | ||
"cases which are assigned to a Case Sharing Group/Location. Learn " | ||
"more about troubleshooting issues with Case Sharing Groups " |
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.
troubleshooting? Confused by that term in a report.
Why are we adding it 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 pulled this text from the acceptance criteria of the linked Jira ticket, but you make a good point. There's nothing that went wrong, so I can see it being confusing that we're linking to troubleshooting documentation.
I had an offline discussion with Mary regarding the above text and will be changing it to:
Note that when viewing this report by group it will only include cases which are assigned to a Case Sharing Group/Location. To learn more about Case Sharing click on this documentation.
The above change serves to link the user to more general documentation if they'd like to learn more about Case Sharing.
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.
"cases which are assigned to a Case Sharing Group/Location. To learn " | ||
"more about Case Sharing click on " | ||
"<a href='{}' target='blank'>this</a> " | ||
"documentation." |
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.
nit:
Just thinking about more standard ways:
To learn more about Case Sharing click <a href='{}' target='blank'>here</a>.
More about Case Sharing on <a href='{}' target='blank'>this</a> documentation.
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.
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.
👍
@property | ||
@memoized | ||
def view_by_groups(self): | ||
return self.request.GET.get('view_by', None) == 'groups' |
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.
nit: isn't the default value already 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.
This is true. I put this in for better readability on what the default is (also done in other places such as here). No strong feelings with keeping this format however, so I'll remove the default 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.
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.
Thanks for the follow up @zandre-eng
Just minor non blocking suggestions.
@property | ||
@memoized | ||
def selected_groups(self): | ||
slugs = EMWF.get_value(self.request, self.domain) |
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.
nit: we need slugs only if self.has_case_group_filters
is true? So, it can move into the if block?
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.
.size(0) | ||
) | ||
query = query.owner(owner_ids) if self.view_by_groups else query.user_ids_handle_unknown(owner_ids) | ||
|
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.
nit: using if block was definitely more readable like done 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.
const $specialNotice = $("#report-special-notice"); | ||
if ($specialNotice) { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
(urlParams.get('view_by') === 'groups') ? $specialNotice.show() : $specialNotice.hide(); |
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.
Does this make it possible to show/hide the banner instantly when user selects a certain option in the UI? or its just at the time of page load?
if its latter, might be better to just add/skip the section in the template.
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 only gets called when the user clicks "Apply" on the filters or when the page is loaded/refreshed. We could try and get the value from the dropdown and use JQuery to instantly show the banner. This would look something like this:
$(document).ajaxSuccess(function (event, xhr, settings) {
if (settings.url.match(/reports\/async\/case_activity/)) {
setSpecialNoticeVisibility();
$('#report_filter_view_by').on("change", setSpecialNoticeVisibility);
}
});
function setSpecialNoticeVisibility() {
const $specialNotice = $("#report-special-notice");
if ($specialNotice) {
const viewByOption = $('#report_filter_view_by').val();
(viewByOption === 'groups') ? $specialNotice.show() : $specialNotice.hide();
}
}
if its latter, might be better to just add/skip the section in the template.
It is a bit challenging to handle the show logic in the template since this only gets rendered on page load. The only other alternative would be to use something like knockout to dynamically show the banner.
Given the above, I'm not sure if all the extra code justifies showing the banner instantly since the user will still see it when it's relevant. Still, no strong feelings in changing this so that the banner is shown instantly. @mkangia What are your thoughts?
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.
Okay, just checking.
How about we keep it simple and just show that message as a help text on that option itself next to "View by users/groups"? in a information icon? and not as a banner that we show/hide.
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 filter is also being used in the Worker Activity report here. The Worker Activity report data includes cases which aren't directly owned by a specific group, and so the help text wouldn't hold true in this scenario.
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.
Okay.
Fine to leave it as it is @zandre-eng. Thanks for talking this through.
@@ -515,7 +515,7 @@ def rows(self): | |||
|
|||
@property | |||
def get_all_rows(self): | |||
es_results = self.es_queryset(user_ids=self.owner_ids) | |||
es_results = self.es_queryset(owner_ids=self.owner_ids) |
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.
was this a bug?
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.
It was. Silly mistake on my end where I forgot to update the param name for the function call.
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.
Cool, no worries. Glad that it was caught 👍
5937bcf
to
f73fa01
Compare
f73fa01
to
fa208da
Compare
Product Description
A new filter is added to change whether the cases in the report should be grouped by user or group/location:
This filter only appears if the domain has case sharing enabled. Additionally, a notice will be shown on the report if the above filter is enabled:
When the view by filter is set to "Groups" the report will only show groups/locations (users will not be shown):
It should be noted that even if one or more users are selected to filter by, the report will simply default to showing all groups/locations.
Technical Summary
Link to ticket here.
The "Case Activity" report has been reworked to support showing report data for cases that are owned by case sharing groups or locations. This is different from something like the Case List report where filtering by a group will also show cases owned by a mobile worker that belong in a specific group.
Given how tightly integrated the report is with expecting user data, some rework has been done to support both users and groups/locations. This includes:
RowData
class for holding user/group data such as name and ID.users_by_id
have all been refactored (e.g.owners_by_id
) to handle either users or groups/locationsget_raw_user_link()
function to accommodate getting links for groups/locations as well as users.Feature Flag
None
Safety Assurance
Safety story
Automated test coverage
No automated tests exist for this report.
QA Plan
QA has been done. Ticket is available here.
Rollback instructions
Labels & Review