-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Correct tag count #8048
Correct tag count #8048
Conversation
Codecov Report
@@ Coverage Diff @@
## main #8048 +/- ##
==========================================
- Coverage 81.69% 79.88% -1.81%
==========================================
Files 100 100
Lines 5845 5866 +21
==========================================
- Hits 4775 4686 -89
- Misses 1070 1180 +110
|
@jywarren @cesswairimu Please review 😄 |
This looks good to me @urvashigupta7 |
@@ -32,7 +34,7 @@ | |||
</div> | |||
|
|||
<div class="card-footer" style="background-color: inherit; border:none;"> | |||
<a style="padding-top:15px;text-decoration:underline;color:#808080;display:inline-block;" href="/tag/<%= tag.name %>"><%= Tag.counter(tag.name)-shown_nids.count - Tag.find_nodes_by_type(tag.name, type = 'note', limit = 3).where.not(nid: shown_nids).count %> <%= translation('tag.index.more_posts') %> »</a> |
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.
Aha - so, i think here we actually do need to keep -shown_nids.count
because that takes the total, but deducts the currently displayed posts because the link says X more posts
-- does that make sense? I think your fix should still work because it resolves the spam filtering on line 119 of the controller.
Can you re-add the offset for the already-displayed posts? Thank you!!!
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.
Just a doubt @jywarren 😅, for example, we have 2 posts with tag one and 1 post with tag one and two both,
and all the 3 posts gets displayed in the topic card for tag one. So, topic card of two should show 0 more posts since the post which had both tags(one and two) is displayed already in topic card of tag-one. I guess this is the thing we want here, 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.
Aha - yes. So we could maybe use this syntax --
[Tag.counter(tag.name)-shown_nids.count - Tag.find_nodes_by_type(tag.name, type = 'note', limit = 3).where.not(nid: shown_nids).count, 0].max
?
Thank you for taking this up @urvashigupta7 ! 🌟🔢 |
@ebarry 😄 |
Thanks @jywarren ! Thank you @urvashigupta7 , what do you think of Jeff's last comment ? |
@ebarry I tried the changes suggested by him. But, I think it is not producing the right results 🤔 Correct me if I am wrong 😅 |
@@ -32,7 +34,7 @@ | |||
</div> | |||
|
|||
<div class="card-footer" style="background-color: inherit; border:none;"> | |||
<a style="padding-top:15px;text-decoration:underline;color:#808080;display:inline-block;" href="/tag/<%= tag.name %>"><%= Tag.counter(tag.name)-shown_nids.count - Tag.find_nodes_by_type(tag.name, type = 'note', limit = 3).where.not(nid: shown_nids).count %> <%= translation('tag.index.more_posts') %> »</a> | |||
<a style="padding-top:15px;text-decoration:underline;color:#808080;display:inline-block;" href="/tag/<%= tag.name %>"><%= [Tag.counter(tag.name) - shown_nids.count - Tag.find_nodes_by_type(tag.name, type = 'note', limit = 3).where.not(nid: shown_nids).count, 0].max %> <%= translation('tag.index.more_posts') %> »</a> |
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.
<a style="padding-top:15px;text-decoration:underline;color:#808080;display:inline-block;" href="/tag/<%= tag.name %>"><%= [Tag.counter(tag.name) - shown_nids.count - Tag.find_nodes_by_type(tag.name, type = 'note', limit = 3).where.not(nid: shown_nids).count, 0].max %> <%= translation('tag.index.more_posts') %> »</a> | |
<a style="padding-top:15px;text-decoration:underline;color:#808080;display:inline-block;" href="/tag/<%= tag.name %>"><%= [Tag.counter(tag.name) - Tag.find_nodes_by_type(tag.name, type = 'note').where(nid: shown_nids).count, 0].max %> <%= translation('tag.index.more_posts') %> »</a> |
I'm really sorry - due to errors in our GitPod setup (#8177 (comment)) we can't test this out in GitPod. If you're able to pull this down to see if it works, we could complete it that way! Or I can try myself in the next few days. Thank you for your patience!!! |
Line 95 in cd9bd3a
This method suplies default value for limit, that means it can return maximum 10,but we don't want that, we want count of all the tags shown above it . Should I make another method which doesn't limit the tag count? Or Is there any other approach for doing this? |
We can make a new method which takes three arguments - tag name, type, shown_nids and it will directly return the count of tags above it. |
I believe that due to the way Line 114 in cd9bd3a
i can see the logic here but i worry it's not a widely enough used function to make it worthwhile! However, you're right that we could then write a simple unit test for it and so better protect it. I'm going to try pulling down this code to manually test, and see how we do. |
Also closing and reopening to try to retrigger the tests, which look to have gotten stuck! |
Hi, @urvashigupta7 I've just had an insight that makes me feel kind of silly -- why do we really need to say I also finally found that we had both a Thank you so much for going through this journey together! It's been pretty convoluted and I want to be sure you feel good about it, and know how much we appreciate it. Is there another issue you'd like to try to take up that might end up being a little easier? This one was really not very typical, i have to say, but you've been great to work with. Thank you!!! |
Thank you soo much @jywarren. I will look into other issues for sure. |
Fixes #7965
Screenshot
It can be seen there are 4 research notes, 1question,5 wiki pages with tag one which sums to 10
The topic card for tag one is now showing the correct count.