Plots2: Contributor count on tag pages not reflecting number of contributors

Created on 4 Nov 2019  Â·  5Comments  Â·  Source: publiclab/plots2

I was looking for the number of posts and contributors to this tag (https://publiclab.org/tag/oil-and-gas) and saw that the number was listed here as Zero:
Screen Shot 2019-11-04 at 11 59 38 AM

But there are actually 73 contributors and 38 posts. This can be found here https://publiclab.org/contributors/oil-and-gas:
Screen Shot 2019-11-04 at 12 00 54 PM

bug fto-candidate help wanted

Most helpful comment

You are very welcome. I totally agree with you...... trust me. But since this isn't my code, I didn't want to edit out their usage of certain definitions; I was just using what they gave me. I'll submit this PR using @title, then, if someone wants to refactor the code to redefine @title to mean something else, I'll just let them have that responsibility. =)

EDIT: Due to my conversation with @jywarren in #6592, the PR for this issue will replace @title with params[:id] in locations where the code is referencing the params passed from the previous link, not where it refers to the page header title.

All 5 comments

great catch!

So, here are the queries used for the 0 posts by 0 contributors | 0 followers area:

https://github.com/publiclab/plots2/blob/8128a3053f9a145599ed58db27cf2d2ad50ca500/app/views/tag/show.html.erb#L57-L61

Here's somewhere they seem to be counting correctly, in the lower right of the main image:

https://github.com/publiclab/plots2/blob/8128a3053f9a145599ed58db27cf2d2ad50ca500/app/views/tag/show/_header.html.erb#L18

Is it possible that tag.name is not correct?

Yes! This relates to the error on

https://github.com/publiclab/plots2/blob/8128a3053f9a145599ed58db27cf2d2ad50ca500/app/views/tag/show.html.erb#L28

This has the same error! https://github.com/publiclab/plots2/issues/6592

We should be able to solve both by replacing tag.name with params[:id] for these lines.


This has been marked as a good candidate for becoming a first-timers-only issue like these, meaning that it's simple, self-contained, and with some extra formatting, could be a great entry point for a new contributor. If you're familiar enough with this code, please consider reformatting or reposting it as a first-timers-only issue, and then ping @publiclab/reviewers to get it labelled. Or, if this is not your first time, try to solve it yourself!

I would also like to piggy-back off of @jywarren to mention that the entire show.html.erb code should be refactored to include the instance variable @title since the tag_controller.rb file has @title = params[:id]. Since we should be practicing DRY, it is redundant to have params[:id] in the show.html.erb file when it was passed along as the @title instance variable from the tag_controller.rb.

Hi, ah, i see - so @title is used to set the HTML document title field, so
I am a little hesitant about using it for this logic just as it's currently
named for a different purpose -- it could cause some confusion. If we'd
like to independently use a new instance variable like @tagname, that could
work, but it may not save us much code. Thanks a lot!

On Mon, Nov 4, 2019 at 2:11 PM nicoleiocana notifications@github.com
wrote:

I would also like to piggy-back off of @jywarren
https://github.com/jywarren to mention that the entire show.html.erb
code should be refactored to include the instance variable @title
https://github.com/title since the tag_controller.rb file has @title =
params[:id]. Since we should be practicing DRY, it is redundant to have
params[:id] in the show.html.erb file when it was passed along as the
@title https://github.com/title instance variable from the
tag_controller.rb.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/6675?email_source=notifications&email_token=AAAF6J4T3LZU5SI3AYYSH6DQSBXUDA5CNFSM4JIWPCCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDAL6JA#issuecomment-549502756,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAF6J5QCPZFUW55BW3F2RDQSBXUDANCNFSM4JIWPCCA
.

You are very welcome. I totally agree with you...... trust me. But since this isn't my code, I didn't want to edit out their usage of certain definitions; I was just using what they gave me. I'll submit this PR using @title, then, if someone wants to refactor the code to redefine @title to mean something else, I'll just let them have that responsibility. =)

EDIT: Due to my conversation with @jywarren in #6592, the PR for this issue will replace @title with params[:id] in locations where the code is referencing the params passed from the previous link, not where it refers to the page header title.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grvsachdeva picture grvsachdeva  Â·  3Comments

divyabaid16 picture divyabaid16  Â·  3Comments

noi5e picture noi5e  Â·  3Comments

grvsachdeva picture grvsachdeva  Â·  3Comments

milaaraujo picture milaaraujo  Â·  3Comments