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

Add num_annotations to js-config group context #8939

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

seanh
Copy link
Contributor

@seanh seanh commented Sep 6, 2024

The frontend is going to need this in order to show a warning dialog when changing the type of a group: the warning only needs to be shown of there are shared annotations in the group. Also, the warning needs to include the number of annotations in the text. See #8898.

Testing

  1. Go to http://localhost:5000/groups/new and create a new group
  2. Go to the group's edit page
  3. View source and search for "num_annotations" in the js-config in the HTML. You should see "num_annotations: 0"
  4. Go to http://localhost:5000/docs/help and create an annotation in the new group. Reload the view-source of the group edit page, you should see "num_annotations": 1
  5. Create a reply, you should see "num_annotations": 2
  6. Create an only-me annotation: "num_annotations" should not change
  7. Delete annotations and "num_annotations" should decrease
  8. In another browser log in as a different user, join the group, and create an annotation in the group: "num_annotations" should increase

@seanh seanh changed the title Add num_annotations to js-config group context Add num_annotations to js-config group context Sep 6, 2024
Copy link
Member

@marcospri marcospri left a comment

Choose a reason for hiding this comment

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

I had a question about the naming of a parameter (or the need for it in the first place) but this look good 👍


This counts all of the group's annotations and replies from all users.

If `unshared=True` then "Only Me" annotations and replies in the group
Copy link
Member

Choose a reason for hiding this comment

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

I had trouble passing this parameter meaning.

It might be clearer with a more verbose name? include_only_me? Not sure

@@ -58,6 +59,9 @@ def _js_config(self):
"link": self.request.route_url(
"group_read", pubid=group.pubid, slug=group.slug
),
"num_annotations": self.annotation_stats_service.total_group_annotation_count(
group.pubid, unshared=False
Copy link
Member

Choose a reason for hiding this comment

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

is unshared always going to be False? Or are you thinking ahead of an immediate need for other type of group?

@@ -58,6 +59,9 @@ def _js_config(self):
"link": self.request.route_url(
"group_read", pubid=group.pubid, slug=group.slug
),
"num_annotations": self.annotation_stats_service.total_group_annotation_count(
group.pubid, unshared=False
Copy link
Member

Choose a reason for hiding this comment

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

is unshared always going to be False? Or are you thinking ahead of an immediate need for other type of group?

@@ -193,6 +193,20 @@ def __call__(self, search, params):
)


class SharedAnnotationsFilter:
Copy link
Member

Choose a reason for hiding this comment

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

I'm always caught by surprise about how this API works, with these callable classes to represent different filters.

🤷 Anyway this fits in the overall current design.

@seanh seanh force-pushed the add-shared-mock-AnnotationStatsService branch from 4da3419 to ffe4796 Compare September 10, 2024 09:25
Base automatically changed from add-shared-mock-AnnotationStatsService to main September 10, 2024 09:28
@seanh seanh force-pushed the add-num-annotations-to-jsconfig branch from 998570d to d71a933 Compare September 10, 2024 09:29
@seanh seanh merged commit d299bd6 into main Sep 10, 2024
9 checks passed
@seanh seanh deleted the add-num-annotations-to-jsconfig branch September 10, 2024 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants