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
Tag.joins(:tag_name)
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('tag_names.name LIKE ?', "%#{ name }%") if name
@@ -83,7 +83,7 @@ class TagsController < ApplicationController
tags =
Tag
.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(id: tag_ids)
.order('tag_names.name')
@@ -128,7 +128,7 @@ class TagsController < ApplicationController
end

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

canonical_hit =
@@ -153,7 +153,7 @@ class TagsController < ApplicationController

def show
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])
if tag
render json: TagRepr.base(tag)
@@ -167,7 +167,7 @@ class TagsController < ApplicationController
return head :bad_request if name.blank?

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: })
if tag
render json: TagRepr.base(tag)
@@ -202,7 +202,7 @@ class TagsController < ApplicationController
return head :bad_request if name.blank?

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: })
return head :not_found unless tag



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

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

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

Loading…
Cancel
Save