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

Filter spam tags from /stats/subscriptions #7831

Closed
jywarren opened this issue Apr 21, 2020 · 2 comments · Fixed by #7851
Closed

Filter spam tags from /stats/subscriptions #7831

jywarren opened this issue Apr 21, 2020 · 2 comments · Fixed by #7851
Labels
fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute Ruby ws used by staff for internal tracking
Milestone

Comments

@jywarren
Copy link
Member

jywarren commented Apr 21, 2020

@ebarry reports:

Not urgent, but there are many spammy tags that have already been deleted from publiclab.org pages that are still showing up in the "0-9" subscriptions area of this page: https://publiclab.org/stats/subscriptions

We can edit the stats controller so that only tags that have at least one published node attached are displayed.

More in a moment (github outage!)

Here is the controller where we collect the tags:

def subscriptions
@tags = {}
TagSelection.where(following: true).each do |tag|
@tags[tag.tagname] = @tags[tag.tagname] || 0
@tags[tag.tagname] += 1
end
@tags = @tags.group_by { |_k, v| v / 10 }
end

I think we can just add .joins(:node) ? If so this could be a FTO...!

Tag.joins(:node)

It may need to be .joins(:tag, :node) ? This can be tested on the rails console.

@jywarren jywarren added help wanted requires help by anyone willing to contribute Ruby labels Apr 21, 2020
@jywarren jywarren added this to the Spam! milestone Apr 21, 2020
@emilyashley emilyashley added the ws used by staff for internal tracking label Apr 21, 2020
@jywarren
Copy link
Member Author

OK, confirmed that just .joins(:node_tags) works! Let's make this an FTO!


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!

@jywarren jywarren added the fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet label Apr 21, 2020
@jywarren
Copy link
Member Author

jywarren commented Apr 28, 2020

Just to clarify, this would become:

TagSelection.where(following: true)
            .joins(:node_tags)
            .each do |tag| 

starting on line 4 of the code referenced above!

cesswairimu added a commit that referenced this issue May 3, 2020
…er.rb (#7851)

* Fixed filter spam tags in app/controllers/stats_controller.rb

* Updated to: where method before joins method

* rearrange where before joins

Co-authored-by: Cess <cessmbuguar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute Ruby ws used by staff for internal tracking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants