publiclab / plots2

a collaborative knowledge-exchange platform in Rails; we welcome first-time contributors! :balloon:
https://publiclab.org
GNU General Public License v3.0
961 stars 1.83k forks source link

Non-project wiki page mysteriously appearing in project pages listing #8808

Closed jywarren closed 3 years ago

jywarren commented 3 years ago

This page: https://publiclab.org/wiki/name-your-project-here

is appearing in a list of pages tagged with project:

https://publiclab.org/wiki/projects#Example+Project+Pages

image

Very oddly, it happens when we run the matching db query:

irb(main):006:0> Node.where(status: 1, type: 'page').includes(:revision,:tag).references(:term_data, :node_revisions).where('term_data.name = ?', 'project').collect(&:title)
=> ["Urban Waters Mapping, NOLA", "Bourj Al Shamali Refugee Camp", "Mapping the Waste Stream of Southern California", "Public Lab River Rat Pack", "The Sand Sentinel Program", "Urban greening in Nottingham", "Wateristic: an underwater bioluminescence detector", "OneCranston", "Unearthing Providence", "Orangetown Aluf", "Agrotóxicos en Cosquín - Argentina", "Name your project here", "Monitoring Bee Behavior with a Raspberry Pi", "Bucket Monitor "]

Working from this code which returns the "Name your project here" page --

https://github.com/publiclab/plots2/blob/c069cfbec093ede01d8731d3b60b91b452b5f84e/app/models/node.rb#L622-L625

But not sure why! See, it has no project tag:

irb(main):007:0> n.tags.collect(&:name)
=> ["gulf-coast", "coastline", "erosion", "3dmodeling", "ccc", "land-loss", "modeling"]

Hmmmm, very strange! This bears some more investigation 🕵️

manchere commented 3 years ago

@jywarren I would like to work on this please

manishaag7 commented 3 years ago

Can i work on this @jywarren

jywarren commented 3 years ago

I appreciate your offers of help! I'm not sure this one will be easy to solve without a copy of the full database or access to a console. I apologize!!!

manishaag7 commented 3 years ago

ok I understand , thanks for replying.

jywarren commented 3 years ago

Gosh this is mysterious. I looked for all NodeTags with both tid = 14751 ('project') and nid = 18422 (our mysterious wiki page) and it returns nothing ([]).

But:

> Node.where(nid: NodeTag.where(tid:14751).collect(&:nid),slug:"name-your-project-here")
=> #<ActiveRecord::Relation [#<Node nid: 24653, vid: 44087, type: "page", language: "", title: "Name your project here", uid: 721831, status: 1, created: 1601087860, changed: 1601087860, comment: 0, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/wiki/name-your-project-here", main_image_id: nil, slug: "name-your-project-here", views: 0, latitude: nil, longitude: nil, precision: nil, flag: 0>]>

I'm missing something obvious?

jywarren commented 3 years ago

Ah, strangely i guess i had the nid wrong: this does return the record:

irb(main):034:0> NodeTag.where(tid:14751,nid:24653)

jywarren commented 3 years ago

And there's the issue. There are 2 records for this page:

irb(main):035:0> Node.find(18422)
=> #<Node nid: 18422, vid: 41802, type: "page", language: "", title: "Coastal Construction Crew 504: Investigating Coast...", uid: 518193, status: 1, created: 1551131573, changed: 1633305497, comment: 0, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 3, path: "/wiki/name-your-project-here", main_image_id: nil, slug: "name-your-project-here", views: 210, latitude: nil, longitude: nil, precision: nil, flag: 8>
irb(main):036:0> Node.find(24653)
=> #<Node nid: 24653, vid: 44087, type: "page", language: "", title: "Name your project here", uid: 721831, status: 1, created: 1601087860, changed: 1601087860, comment: 0, promote: 0, moderate: 0, sticky: 0, tnid: 0, translate: 0, cached_likes: 0, comments_count: 0, drupal_node_revisions_count: 1, path: "/wiki/name-your-project-here", main_image_id: nil, slug: "name-your-project-here", views: 0, latitude: nil, longitude: nil, precision: nil, flag: 0>

The latter one, which was hidden by the other, has the project tag. I'll delete it and the node.