From 91eeaa33a436ba2233f1fe7509f7c104db1d4533 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 13 Jan 2018 17:56:33 -0500 Subject: Replaced GROUP clause in front page query with DISTINCT Apparently the choice of row to be returned with a GROUP that uses fields outside of ones that are functionally dependent on the GROUP fields is arbitrary, as per https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html --- app/controllers/pokeviewer/pokemon_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/controllers/pokeviewer/pokemon_controller.rb b/app/controllers/pokeviewer/pokemon_controller.rb index 86b0ea6..0e19c6a 100644 --- a/app/controllers/pokeviewer/pokemon_controller.rb +++ b/app/controllers/pokeviewer/pokemon_controller.rb @@ -3,12 +3,12 @@ require_dependency "pokeviewer/application_controller" module Pokeviewer class PokemonController < ApplicationController def index - pokemon = Pokemon.joins(:current). - order("trainer_id IS NULL DESC"). + pokemon = Pokemon.order("trainer_id IS NULL DESC"). order(trainer_id: :asc). order(box: :asc). order(slot: :asc). - group("pokeviewer_pokemon.uuid"). + select(:uuid).distinct. + order("pokeviewer_revisions.sequential_id DESC"). includes(:current). chunk do |p| if p.trainer_id.nil? -- cgit 1.4.1