Skip to content
Extraits de code Groupes Projets
Valider b65bf66f rédigé par Sybil's avatar Sybil
Parcourir les fichiers

Corrections to the ugly query.

parent 2a7c64bd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -5,4 +5,9 @@ class TagsController < ApplicationController
render json: @tags, status: 200
end
def tagsFilter
@tags = Tag.limit(100).order(quantity: :desc)
render json: @tags, status: 200
end
end
......@@ -19,7 +19,7 @@ class TracksController < ApplicationController
when :tag, :channel, :user
query.concat" #{filter}s.name='#{param}'"
when :date
query.concat(" irc_posts.posted_at='#{param}'")
query.concat(" date(irc_posts.posted_at)='#{param}'")
end
end
end
......@@ -51,8 +51,14 @@ class TracksController < ApplicationController
def filtersOptimized( *filters )
condition = filterCondition( filters )
query = filterQuery( filters )
if [:channel, :user, :date].any? {|param| params.has_key? param}
@tracks = Track.joins(query).where(condition).group(:track_id).page params[:page]
else
@tracks = Track.joins(query).where(condition).page params[:page]
end
end
def index
#@tracks = Track.includes(:tags).page params[:page]
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter