use current_scores instead of scores

This commit is contained in:
Scott Comer 2014-06-10 20:50:59 -05:00
parent e5b1aa0e6a
commit 161f75a126
1 changed files with 11 additions and 11 deletions

View File

@ -213,14 +213,14 @@ module JamRuby
# the default of ANY setup above applies
end
rel = rel.joins("#{score_join} join scores on scores.alocidispid = users.last_jam_locidispid")
.where(['(scores.blocidispid = ? or scores.blocidispid is null)', locidispid])
rel = rel.joins("#{score_join} join current_scores on current_scores.alocidispid = users.last_jam_locidispid")
.where(['(current_scores.blocidispid = ? or current_scores.blocidispid is null)', locidispid])
rel = rel.where(['scores.score > ?', score_min]) unless score_min.nil?
rel = rel.where(['scores.score <= ?', score_max]) unless score_max.nil?
rel = rel.where(['current_scores.score > ?', score_min]) unless score_min.nil?
rel = rel.where(['current_scores.score <= ?', score_max]) unless score_max.nil?
rel = rel.select('scores.score')
rel = rel.group('scores.score')
rel = rel.select('current_scores.score')
rel = rel.group('current_scores.score')
end
ordering = self.order_param(params)
@ -242,7 +242,7 @@ module JamRuby
end
unless locidispid.nil?
rel = rel.order('scores.score ASC NULLS LAST')
rel = rel.order('current_scores.score ASC NULLS LAST')
end
rel = rel.order('users.created_at DESC')
@ -391,10 +391,10 @@ module JamRuby
rel = User.musicians_geocoded
.where(['created_at >= ? AND users.id != ?', since_date, usr.id])
.joins('inner join scores on users.last_jam_locidispid = scores.alocidispid')
.where(['scores.blocidispid = ?', locidispid])
.where(['scores.score <= ?', score_limit])
.order('scores.score') # best scores first
.joins('inner join current_scores on users.last_jam_locidispid = current_scores.alocidispid')
.where(['current_scores.blocidispid = ?', locidispid])
.where(['current_scores.score <= ?', score_limit])
.order('current_scores.score') # best scores first
.order('users.created_at DESC') # then most recent
.limit(limit)