-
Notifications
You must be signed in to change notification settings - Fork 25
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
Category count cleanup #5718
Category count cleanup #5718
Changes from all commits
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 |
---|---|---|
|
@@ -826,7 +826,7 @@ def build_context_menu(self, menu): | |
) | ||
|
||
if self.has_org_perm("flows.flow_results"): | ||
menu.add_link(_("Results"), reverse("flows.flow_results", args=[obj.uuid])) | ||
menu.add_link(_("Results"), reverse("flows.flow_results", args=[obj.id])) | ||
|
||
menu.new_group() | ||
|
||
|
@@ -1121,6 +1121,10 @@ def create_export(self, org, user, form): | |
) | ||
|
||
class Engagement(BaseReadView): | ||
""" | ||
Data for charts on engagement tab of results page. | ||
""" | ||
|
||
permission = "flows.flow_results" | ||
|
||
def render_to_response(self, context, **response_kwargs): | ||
|
@@ -1216,46 +1220,31 @@ def render_to_response(self, context, **response_kwargs): | |
|
||
class CategoryCounts(BaseReadView): | ||
""" | ||
Used by the editor for the counts on split exits | ||
Data for charts on analytics tab of results page. | ||
""" | ||
|
||
permission = "flows.flow_editor" | ||
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. not used by the editor since we added path counts a million years ago |
||
slug_url_kwarg = "uuid" | ||
permission = "flows.flow_results" | ||
|
||
def render_to_response(self, context, **response_kwargs): | ||
return JsonResponse({"counts": self.object.get_category_counts()}) | ||
|
||
class Results(SpaMixin, ContextMenuMixin, BaseReadView): | ||
slug_url_kwarg = "uuid" | ||
|
||
def build_context_menu(self, menu): | ||
obj = self.get_object() | ||
|
||
if self.has_org_perm("flows.flow_editor"): | ||
menu.add_link(_("Editor"), reverse("flows.flow_editor", args=[obj.uuid]), as_button=True) | ||
|
||
if self.has_org_perm("flows.flow_results"): | ||
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. don't need to check this perm because this is the perm of this view |
||
menu.add_modax( | ||
_("Export"), | ||
"export-results", | ||
f"{reverse('flows.flow_export_results')}?ids={obj.id}", | ||
title=_("Export Results"), | ||
) | ||
menu.add_modax( | ||
_("Export"), | ||
"export-results", | ||
f"{reverse('flows.flow_export_results')}?ids={obj.id}", | ||
title=_("Export Results"), | ||
) | ||
|
||
def get_context_data(self, *args, **kwargs): | ||
context = super().get_context_data(*args, **kwargs) | ||
flow = self.object | ||
|
||
result_fields = [] | ||
for result_field in flow.metadata[Flow.METADATA_RESULTS]: | ||
if not result_field["name"].startswith("_"): | ||
result_field = result_field.copy() | ||
result_field["has_categories"] = "true" if len(result_field["categories"]) > 1 else "false" | ||
result_fields.append(result_field) | ||
context["result_fields"] = result_fields | ||
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. Not used tho interesting that this excludes "hidden" (i.e. name starts with |
||
|
||
context["categories"] = flow.get_category_counts() | ||
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. not used - the category counts are fetched via AJAX call to /flow/category_counts/x/ |
||
context["utcoffset"] = int(datetime.now(flow.org.timezone).utcoffset().total_seconds() // 60) | ||
context["utcoffset"] = int(datetime.now(self.request.org.timezone).utcoffset().total_seconds() // 60) | ||
return context | ||
|
||
class Activity(BaseReadView): | ||
|
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 think 'All responses' is used by U-Report
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.
But U-Report isn't using category counts.. right?
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.
Possible, I will check again
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.
Correct we do not rely on these counts