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

barnstar listings on profiles are not consistent; poor join #39

Closed
jywarren opened this issue Apr 21, 2014 · 0 comments
Closed

barnstar listings on profiles are not consistent; poor join #39

jywarren opened this issue Apr 21, 2014 · 0 comments

Comments

@jywarren
Copy link
Member

https://github.com/publiclab/plots2/blob/master/app/models/user.rb#L142-L148

This is not working for all profiles due to improper join; only some profiles correctly report the barnstars they have:

> nids = DrupalNode.find_all_by_uid(554, :conditions => {:type => "note"}, :order => "created DESC", :select => :nid).collect(&:nid)

node Columns (3.3ms)  SHOW FIELDS FROM `node`
DrupalNode Load (0.3ms)  SELECT nid FROM `node` WHERE `node`.`type` = 'note' AND `node`.`uid` = 554 ORDER BY created DESC
=> [8928, 8926, ... 1676, 1652, 1541, 831] 

> DrupalNodeCommunityTag.find :all, :conditions => ["name LIKE ? AND nid IN (?)",'barnstar:%',nids.join(',')], :joins => :drupal_tag

community_tags Columns (3.0ms)  SHOW FIELDS FROM `community_tags`
term_data Columns (2.2ms)  SHOW FIELDS FROM `term_data`
DrupalNodeCommunityTag Load (1.2ms)  SELECT `community_tags`.* FROM `community_tags` INNER JOIN `term_data` ON `term_data`.`tid` = `community_tags`.`tid` WHERE (name LIKE 'barnstar:%' AND nid IN ('8928,8926, ... 1541,831'))
=> [] 

However, manually changing it to outer join doesn't work either:

> DrupalNodeCommunityTag.find :all, :conditions => ["name LIKE ? AND nid IN (?) OUTER JOIN term_node ON term_node.tid = community_tags.tid",'barnstar:%',nids.join(',')]#, :joins => :drupal_tag

Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OUTER JOIN term_node ON term_node.tid = community_tags.tid)' at line 1: SELECT `community_tags`.* FROM `community_tags`  WHERE (name LIKE 'barnstar:%' AND nid IN ('8928,8926, ... 1652,1541,831') OUTER JOIN term_node ON term_node.tid = community_tags.tid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant