Browse Source

#99

feature/099
みてるぞ 1 week ago
parent
commit
e916b4a113
2 changed files with 7 additions and 7 deletions
  1. +6
    -6
      backend/app/controllers/tags_controller.rb
  2. +1
    -1
      backend/app/representations/material_repr.rb

+ 6
- 6
backend/app/controllers/tags_controller.rb View File

@@ -33,7 +33,7 @@ class TagsController < ApplicationController
else else
Tag.joins(:tag_name) Tag.joins(:tag_name)
end end
.includes(:tag_name, tag_name: :wiki_page, :materials)
.includes(:tag_name, :materials, tag_name: :wiki_page)
q = q.where(posts: { id: post_id }) if post_id.present? q = q.where(posts: { id: post_id }) if post_id.present?


q = q.where('tag_names.name LIKE ?', "%#{ name }%") if name q = q.where('tag_names.name LIKE ?', "%#{ name }%") if name
@@ -83,7 +83,7 @@ class TagsController < ApplicationController
tags = tags =
Tag Tag
.joins(:tag_name) .joins(:tag_name)
.includes(:tag_name, tag_name: :wiki_page, :materials)
.includes(:tag_name, :materials, tag_name: :wiki_page)
.where(category: [:meme, :character, :material]) .where(category: [:meme, :character, :material])
.where(id: tag_ids) .where(id: tag_ids)
.order('tag_names.name') .order('tag_names.name')
@@ -128,7 +128,7 @@ class TagsController < ApplicationController
end end


base = Tag.joins(:tag_name) base = Tag.joins(:tag_name)
.includes(:tag_name, tag_name: :wiki_page, :materials)
.includes(:tag_name, :materials, 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 =
@@ -153,7 +153,7 @@ class TagsController < ApplicationController


def show def show
tag = Tag.joins(:tag_name) tag = Tag.joins(:tag_name)
.includes(:tag_name, tag_name: :wiki_page, :materials)
.includes(:tag_name, :materials, tag_name: :wiki_page)
.find_by(id: params[:id]) .find_by(id: params[:id])
if tag if tag
render json: TagRepr.base(tag) render json: TagRepr.base(tag)
@@ -167,7 +167,7 @@ class TagsController < ApplicationController
return head :bad_request if name.blank? return head :bad_request if name.blank?


tag = Tag.joins(:tag_name) tag = Tag.joins(:tag_name)
.includes(:tag_name, tag_name: :wiki_page, :materials)
.includes(:tag_name, :materials, tag_name: :wiki_page)
.find_by(tag_names: { name: }) .find_by(tag_names: { name: })
if tag if tag
render json: TagRepr.base(tag) render json: TagRepr.base(tag)
@@ -202,7 +202,7 @@ class TagsController < ApplicationController
return head :bad_request if name.blank? return head :bad_request if name.blank?


tag = Tag.joins(:tag_name) tag = Tag.joins(:tag_name)
.includes(:tag_name, tag_name: :wiki_page)
.includes(:tag_name, :materials, tag_name: :wiki_page)
.find_by(tag_names: { name: }) .find_by(tag_names: { name: })
return head :not_found unless tag return head :not_found unless tag




+ 1
- 1
backend/app/representations/material_repr.rb View File

@@ -19,6 +19,6 @@ module MaterialRepr
end end


def many materials, host: def many materials, host:
materials.map { |m| base(m, host) }
materials.map { |m| base(m, host:) }
end end
end end

Loading…
Cancel
Save