This commit is contained in:
@@ -6,7 +6,9 @@ class NicoTagsController < ApplicationController
|
|||||||
cursor = params[:cursor].presence
|
cursor = params[:cursor].presence
|
||||||
|
|
||||||
q = Tag.nico_tags
|
q = Tag.nico_tags
|
||||||
.includes(:tag_name, linked_tags: :tag_name)
|
.joins(:tag_name)
|
||||||
|
.left_joins(tag_name: :wiki_page)
|
||||||
|
.includes(:tag_name, tag_name: :wiki_page, linked_tags: :tag_name)
|
||||||
.order(updated_at: :desc)
|
.order(updated_at: :desc)
|
||||||
q = q.where('tags.updated_at < ?', Time.iso8601(cursor)) if cursor
|
q = q.where('tags.updated_at < ?', Time.iso8601(cursor)) if cursor
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,15 @@ class TagsController < ApplicationController
|
|||||||
|
|
||||||
tags =
|
tags =
|
||||||
if post_id.present?
|
if post_id.present?
|
||||||
Tag.joins(:posts).where(posts: { id: post_id })
|
Tag.joins(:posts, :tag_name)
|
||||||
else
|
else
|
||||||
Tag.all
|
Tag.joins(:tag_name)
|
||||||
end
|
end
|
||||||
|
.left_joins(tag_name: :wiki_page)
|
||||||
|
.includes(:tag_name, tag_name: :wiki_page)
|
||||||
|
if post_id.present?
|
||||||
|
tags = tags.where(posts: { id: post_id })
|
||||||
|
end
|
||||||
|
|
||||||
render json: tags.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki])
|
render json: tags.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki])
|
||||||
end
|
end
|
||||||
@@ -33,7 +38,9 @@ class TagsController < ApplicationController
|
|||||||
matched_alias_by_tag_name_id[canonical_id] ||= alias_name
|
matched_alias_by_tag_name_id[canonical_id] ||= alias_name
|
||||||
end
|
end
|
||||||
|
|
||||||
base = Tag.joins(:tag_name).includes(:tag_name)
|
base = Tag.joins(:tag_name)
|
||||||
|
.left_joins(tag_name: :wiki_page)
|
||||||
|
.includes(:tag_name, tag_name: :wiki_page)
|
||||||
base = base.where('tags.post_count > 0') if present_only
|
base = base.where('tags.post_count > 0') if present_only
|
||||||
|
|
||||||
canonical_hit =
|
canonical_hit =
|
||||||
@@ -58,7 +65,10 @@ class TagsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
tag = Tag.find_by(id: params[:id])
|
tag = Tag.joins(:tag_name)
|
||||||
|
.left_joins(tag_name: :wiki_page)
|
||||||
|
.includes(:tag_name, tag_name: :wiki_page)
|
||||||
|
.find_by(id: params[:id])
|
||||||
if tag
|
if tag
|
||||||
render json: tag.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki])
|
render json: tag.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki])
|
||||||
else
|
else
|
||||||
@@ -70,7 +80,10 @@ class TagsController < ApplicationController
|
|||||||
name = params[:name].to_s.strip
|
name = params[:name].to_s.strip
|
||||||
return head :bad_request if name.blank?
|
return head :bad_request if name.blank?
|
||||||
|
|
||||||
tag = Tag.joins(:tag_name).includes(:tag_name).find_by(tag_names: { name: })
|
tag = Tag.joins(:tag_name)
|
||||||
|
.left_joins(tag_name: :wiki_page)
|
||||||
|
.includes(:tag_name, tag_name: :wiki_page)
|
||||||
|
.find_by(tag_names: { name: })
|
||||||
if tag
|
if tag
|
||||||
render json: tag.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki])
|
render json: tag.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki])
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ class WikiPagesController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
title = params[:title].to_s.strip
|
title = params[:title].to_s.strip
|
||||||
return render json: WikiPage.all.as_json(methods: [:title]) if title.blank?
|
if title.blank?
|
||||||
|
return render json: WikiPage.joins(:tag_name)
|
||||||
|
.includes(:tag_name)
|
||||||
|
.as_json(methods: [:title])
|
||||||
|
end
|
||||||
|
|
||||||
q = WikiPage.joins(:tag_name).includes(:tag_name)
|
q = WikiPage.joins(:tag_name).includes(:tag_name)
|
||||||
.where('tag_names.name LIKE ?', "%#{ WikiPage.sanitize_sql_like(title) }%")
|
.where('tag_names.name LIKE ?', "%#{ WikiPage.sanitize_sql_like(title) }%")
|
||||||
|
|||||||
Reference in New Issue
Block a user