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

fix: 🍰 Comment Counters Are Now Equal #3769

Closed
wants to merge 8 commits into from
Closed

Conversation

Tirokk
Copy link
Member

@Tirokk Tirokk commented Oct 6, 2020

Elweyn Authored by Elweyn
Aug 3, 2020
Merged Aug 11, 2020


[WIP] 🍰 Pullrequest 2112

Changed the filter so that the comments that are deleted are not counted in the comment number anymore

Issues

Todo

  • Test to check if the updated comment get directly updated on the frontend

@Tirokk
Copy link
Member Author

Tirokk commented Oct 7, 2020

cypress[bot] Authored by cypress[bot]
Aug 3, 2020




Test summary

66 0 0 0


Run details

Project Human-Connection
Status Passed
Commit 823056b
Started Aug 11, 2020 2:22 PM
Ended Aug 11, 2020 2:45 PM
Duration 22:45 💡
OS Linux Ubuntu Linux - 16.04
Browser Firefox 68

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@Tirokk
Copy link
Member Author

Tirokk commented Oct 7, 2020

cypress[bot] Authored by cypress[bot]
Aug 3, 2020




Test summary

66 0 0 0


Run details

Project Human-Connection
Status Passed
Commit 0c3f8c2af0 ℹ️
Started Aug 11, 2020 2:23 PM
Ended Aug 11, 2020 2:47 PM
Duration 24:24 💡
OS Linux Ubuntu Linux - 16.04
Browser Firefox 68

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@Tirokk
Copy link
Member Author

Tirokk commented Oct 7, 2020

Tirokk Authored by Tirokk
Aug 3, 2020


Hey @Elweyn ,

can you run the linter on webapp and on backend.
yarn lint --fix
and push again? That would be great …
That’s the reason why the Travis build fails.

PS: In case you work on the locale files in the webapp please run as well
yarn locales --fix
before you push.
PPS: The semantic PR marker bug: was not correct. fix: is correct in this case … ☝🏼

@Tirokk
Copy link
Member Author

Tirokk commented Oct 7, 2020

Elweyn Authored by Elweyn
Aug 3, 2020


Hey @Tirokk,
thanks was not sure how the semantic had to be done!

I just made the linter on webapp and backend.

content: 'this is a deleted comment',
deleted: true,
author: { id: 'some-user' },
},
Copy link
Member Author

Choose a reason for hiding this comment

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

Tirokk Authored by Tirokk
Aug 4, 2020


Outdated (history rewrite) - original diff


@@ -28,6 +28,13 @@ describe('CommentList.vue', () => {
               content: 'this is a comment',
               author: { id: 'some-user' },
             },
+            {
+              id: 'comment135',
+              contentExcerpt: 'this is a deleted comment',
+              content: 'this is a deleted comment',
+              deleted: true,
+              author: { id: 'some-user' },
+            },

Because of a different solution I suggest in the next comment👇🏼 this test makes no sense anymore.

Would be cool to replace it with a test in backend/src/schema/resolvers/posts.spec.js which checks that only comments not deleted and not disabled are counted by the Cypher queries.

Copy link
Member Author

Choose a reason for hiding this comment

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

Elweyn Authored by Elweyn
Aug 5, 2020


Thanks for the response. I think it is important to check if their are deleted comments that it does not break the other tests, so we could let this one and add another one in backend/src/schema/resolvers/posts.spec.js to check if the count is setten correctly what do you think?

@@ -1,12 +1,12 @@
<template>
<div id="comments" class="comment-list">
<h3 class="title">
<counter-icon icon="comments" :count="postComments.length" />
<counter-icon icon="comments" :count="commentsCount" />
{{ $t('common.comment', null, 0) }}
</h3>
Copy link
Member Author

Choose a reason for hiding this comment

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

Tirokk Authored by Tirokk
Aug 4, 2020


Outdated (history rewrite) - original diff


@@ -1,7 +1,10 @@
 <template>
   <div id="comments" class="comment-list">
     <h3 class="title">
-      <counter-icon icon="comments" :count="postComments.length" />
+      <counter-icon
+        icon="comments"
+        :count="postComments.filter((comment) => !comment.deleted).length"

I looked at the other place in webapp/components/PostTeaser/PostTeaser.vue where the counter is set on a post teaser. This is the part which differs from that here.
Because I know this value of post.commentsCount comes direct from the backend and because I have found this doesn’t count comment.deleted or comment.disabled I will suggest this solution to be taken over here.

Suggested change
</h3>
:count="post.commentsCount“

A test in backend/src/schema/resolvers/posts.spec.js is missing which checks that only comments not deleted and not disabled are counted by the Cypher queries.
If you are motivated would be nice to implement this one. 💫🍀

Copy link
Member Author

Choose a reason for hiding this comment

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

Elweyn Authored by Elweyn
Aug 5, 2020


Thanks a lot, this one seems a lot better than a filter on the deleted comments!
I will implement this so the frontend code stays clean of logic.

@Tirokk
Copy link
Member Author

Tirokk commented Oct 7, 2020

Elweyn Authored by Elweyn
Aug 6, 2020


Hi @Tirokk
after @Mogge and I realised that this class made some trouble with the comment tickets.
We decided to change it so that we don't work on the computed postComments anymore but on post.comments.

Since the value of post.commentsCount is not updated as long as we don't make a reload of the page, we decided to make a computed property commentsCount that make use the first written filter.
So I added a new comment that was disabled to make sure that the count is stil 1 even when their is a disabled comment and a deleted comment.

Hope this seems good.
Cheers

},
},
{
id: 'comment135',
Copy link
Member Author

Choose a reason for hiding this comment

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

Tirokk Authored by Tirokk
Aug 7, 2020


Outdated (history rewrite) - original diff


@@ -28,6 +28,20 @@ describe('CommentList.vue', () => {
               content: 'this is a comment',
               author: { id: 'some-user' },
             },
+            {
+              id: 'comment135',
+              contentExcerpt: 'this is a deleted comment',
+              content: 'this is a deleted comment',
+              deleted: true,
+              author: { id: 'some-user' },
+            },
+            {
+              id: 'comment136',
+              contentExcerpt: 'this is a disabled comment',
+              content: 'this is a disabled comment',
+              disabled: true,
+              author: { id: 'some-user' },
+            },

Okay. Cool!
Then this test extension is needed. 😍

@@ -36,8 +36,13 @@ export default {
},
},
computed: {
Copy link
Member Author

Choose a reason for hiding this comment

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

Tirokk Authored by Tirokk
Aug 7, 2020


Outdated (history rewrite) - original diff


@@ -39,6 +39,14 @@ export default {
     postComments() {
       return (this.post && this.post.comments) || []
     },

This code is now superfluous, I think.

@Tirokk
Copy link
Member Author

Tirokk commented Oct 7, 2020

Mogge Authored by Mogge
Aug 7, 2020


Testing that a comment is updated after editing would be great.

Copy link
Contributor

@Mogge Mogge left a comment

Choose a reason for hiding this comment

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

Hey @Elweyn ,
supercool you have cared for this one. 🚀

Glad to have you in our project!

Copy link
Contributor

@Mogge Mogge left a comment

Choose a reason for hiding this comment

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

Great work. Thanx

@Mogge Mogge closed this Oct 8, 2020
@ulfgebhardt ulfgebhardt deleted the pr3769head branch January 7, 2021 03:32
Tirokk pushed a commit that referenced this pull request Jan 18, 2021
fix: 🍰 Comment Counters Are Now Equal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants