plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

NoMethodError: undefined method `notes_for_tags' for #<User:0x00007f95d21db590>

Open sentry[bot] opened this issue 4 years ago • 8 comments

Sentry Issue: PLOTS2-18A

NoMethodError: undefined method `notes_for_tags' for #<User:0x00007f95d21db590>
Did you mean?  note_streak
  app/controllers/notes_controller.rb:336:in `author_topic'
    @notes = @user.notes_for_tags(@tagnames)
...
(104 additional frame(s) were not displayed)

sentry[bot] avatar Apr 01 '21 16:04 sentry[bot]

Affecting pages like https://publiclab.org/notes/author/kanarinka/water-quality-monitoring

jywarren avatar Apr 01 '21 16:04 jywarren

We should perhaps also ensure we have a functional test for this page!

jywarren avatar Apr 01 '21 16:04 jywarren

Also affecting: https://publiclab.org/notes/author/Sara/events:boston

That's line 336 -

https://github.com/publiclab/plots2/blob/1afcac6d61715fcd346e3b7148a7505697297ca1/app/controllers/notes_controller.rb#L331-L339

I don't know when this method was deleted, but it's nowhere to be found now! Let's just refactor -- we need a query that fetches notes tagged with the given tag, but only by that author.

Probably something like:

  nids = NodeTag.includes(:node, :tag)
    .references(:term_data)
    .where(type: 'note')
    .where(name: tagnames, uid: :uid)
    @pagy, @notes = pagy(Node
      .order('nid DESC')
      .where(nid: nids), items: 24)

@Manasa2850 @17sushmita this is a small but kind of interesting one related to tagging! Would either of you be interested?

jywarren avatar Jul 20 '21 22:07 jywarren

can you explain me the issue a bit more? @TildaDares

Ash-KODES avatar Feb 14 '22 22:02 Ash-KODES

@Ash-KODES The reason for the error is because the notes_for_tags method is missing from the User model. What you need to do is create the notes_for_tags method in user.rb. The method will be something like:

Probably something like:

  nids = NodeTag.includes(:node, :tag)
    .references(:term_data)
    .where(type: 'note')
    .where(name: tagnames, uid: :uid)
    @pagy, @notes = pagy(Node
      .order('nid DESC')
      .where(nid: nids), items: 24)

A few things will have to change like removing the @pagy and pagy variables/method call. I hope that helps.

TildaDares avatar Feb 15 '22 07:02 TildaDares

Hey @TildaDares, can I take up this issue?

KarishmaVanwari avatar Mar 18 '22 15:03 KarishmaVanwari

Hi @KarishmaVanwari, go ahead! Thank you.

TildaDares avatar Mar 18 '22 15:03 TildaDares

Hey @TildaDares, I've opened a PR #10801. Please have a look. Thanks!

KarishmaVanwari avatar Mar 20 '22 14:03 KarishmaVanwari

Hey @TildaDares! Hope you are doing well.

Was this issue ever resolved or can I pick it up?

toshitapandey avatar Oct 04 '22 12:10 toshitapandey

Hi @toshitapandey, please go ahead. Thank you!

TildaDares avatar Oct 04 '22 13:10 TildaDares