Skip to content

Commit

Permalink
Query should search for extra tag while searching (#2864)
Browse files Browse the repository at this point in the history
* added query

* codeclimate correction

* codeclimate correction 2
  • Loading branch information
grvsachdeva authored and jywarren committed Jun 20, 2018
1 parent 75838b1 commit 3a642a0
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions app/controllers/tag_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,28 @@ def show
.order('node_revisions.timestamp DESC')
else
@tags = Tag.where(name: params[:id])
nodes = Node.where(status: 1, type: node_type)
.includes(:revision, :tag)
.references(:term_data, :node_revisions)
.where('term_data.name = ? OR term_data.parent = ?', params[:id], params[:id])
.paginate(page: params[:page], per_page: 24)
.order('node_revisions.timestamp DESC')

if @node_type == 'questions'
if params[:id].include? "question:"
other_tag = params[:id].split(':')[1]
else
other_tag = "question:" + params[:id]
end

nodes = Node.where(status: 1, type: node_type)
.includes(:revision, :tag)
.references(:term_data, :node_revisions)
.where('term_data.name = ? OR term_data.name = ? OR term_data.parent = ?', params[:id], other_tag, params[:id])
.paginate(page: params[:page], per_page: 24)
.order('node_revisions.timestamp DESC')
else
nodes = Node.where(status: 1, type: node_type)
.includes(:revision, :tag)
.references(:term_data, :node_revisions)
.where('term_data.name = ? OR term_data.parent = ?', params[:id], params[:id])
.paginate(page: params[:page], per_page: 24)
.order('node_revisions.timestamp DESC')
end
end
nodes = nodes.where(created: @start.to_i..@end.to_i) if @start && @end

Expand Down

0 comments on commit 3a642a0

Please sign in to comment.