このコミットが含まれているのは:
@@ -7,6 +7,8 @@ class PostsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
locale = resolve_locale!
|
||||
|
||||
url = params[:url].presence
|
||||
title = params[:title].presence
|
||||
original_created_from = params[:original_created_from].presence
|
||||
@@ -46,7 +48,7 @@ class PostsController < ApplicationController
|
||||
'COALESCE(pt_max.max_updated_at, posts.updated_at))'
|
||||
|
||||
q =
|
||||
filtered_posts
|
||||
filtered_posts(locale)
|
||||
.joins("LEFT JOIN (#{ pt_max_sql }) pt_max ON pt_max.post_id = posts.id")
|
||||
.reselect('posts.*', Arel.sql("#{ updated_at_all_sql } AS updated_at_all"))
|
||||
.preload(:external_tags, :uploaded_user, :parents, :children,
|
||||
@@ -102,8 +104,10 @@ class PostsController < ApplicationController
|
||||
end
|
||||
|
||||
def random
|
||||
locale = resolve_locale!
|
||||
|
||||
post =
|
||||
filtered_posts
|
||||
filtered_posts(locale)
|
||||
.preload(:uploaded_user, :parents, :children,
|
||||
post_tags: [:sections, { tag: [:deerjikists, :materials,
|
||||
{ tag_name: :wiki_page }] }])
|
||||
@@ -394,19 +398,19 @@ class PostsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def filtered_posts
|
||||
def filtered_posts locale
|
||||
tag_names = params[:tags].to_s.split
|
||||
match_type = params[:match]
|
||||
if tag_names.present?
|
||||
filter_posts_by_tags(tag_names, match_type)
|
||||
filter_posts_by_tags(locale, tag_names, match_type)
|
||||
else
|
||||
Post.all
|
||||
end
|
||||
end
|
||||
|
||||
def filter_posts_by_tags tag_names, match_type
|
||||
def filter_posts_by_tags locale, tag_names, match_type
|
||||
literals = tag_names.map do |raw_name|
|
||||
{ name: TagName.canonicalise(raw_name.sub(/\Anot:/i, '')).first,
|
||||
{ name: TagName.canonicalise(locale, raw_name.sub(/\Anot:/i, '')).first,
|
||||
negative: raw_name.downcase.start_with?('not:') }
|
||||
end
|
||||
|
||||
|
||||
@@ -430,7 +430,7 @@ class TagsController < ApplicationController
|
||||
else
|
||||
tag.update!(category:, deprecated_at: deprecated ? Time.current : nil)
|
||||
end
|
||||
rename_tag_name!(tag, name) if name_changed
|
||||
rename_tag_name!(locale, tag, name) if name_changed
|
||||
|
||||
alias_names << old_name if name_changed
|
||||
alias_names.delete(name)
|
||||
@@ -701,13 +701,13 @@ class TagsController < ApplicationController
|
||||
false
|
||||
end
|
||||
|
||||
def rename_tag_name! tag, name
|
||||
return if name == tag.name
|
||||
def rename_tag_name! locale, tag, name
|
||||
return if name == tag.name(locale.language_code)
|
||||
|
||||
current_tag_name = tag.tag_name
|
||||
target_tag_name = TagName.find_by(name:)
|
||||
current_tag_name = tag.tag_name(locale.language_code)
|
||||
target_tag_name = TagName.find_by(language_code: locale.language_code, name:)
|
||||
|
||||
if target_tag_name.nil?
|
||||
unless target_tag_name
|
||||
current_tag_name.update!(name:)
|
||||
return
|
||||
end
|
||||
@@ -722,19 +722,21 @@ class TagsController < ApplicationController
|
||||
TagVersioning.ensure_snapshot!(old_owner_tag, created_by_user: current_user)
|
||||
end
|
||||
|
||||
promoted_tag_name.update!(canonical: nil)
|
||||
promoted_tag_name.update!(canonical_id: nil, primary_flg: true)
|
||||
|
||||
TagName.where(canonical_id: current_tag_name.id)
|
||||
TagName.where(tag:,
|
||||
language_code: current_tag_name.language.language_code,
|
||||
primary_flg: false)
|
||||
.where.not(id: promoted_tag_name.id)
|
||||
.find_each do |alias_tag_name|
|
||||
alias_tag_name.update!(canonical: promoted_tag_name)
|
||||
alias_tag_name.update!(canonical_id: promoted_tag_name, primary_flg: false)
|
||||
end
|
||||
|
||||
current_tag_name.wiki_page&.update!(tag_name: promoted_tag_name)
|
||||
tag.update!(tag_name: promoted_tag_name)
|
||||
current_tag_name.wiki_page&.update!(tag_name_id: promoted_tag_name.id)
|
||||
tag.update!(tag_name_id: promoted_tag_name.id)
|
||||
current_tag_name.association(:wiki_page).reset
|
||||
current_tag_name.association(:tag).reset
|
||||
current_tag_name.reload.update!(canonical: promoted_tag_name)
|
||||
current_tag_name.reload.update!(canonical_id: promoted_tag_name, primary_flg: false)
|
||||
|
||||
return unless old_owner_tag && old_owner_tag != tag
|
||||
|
||||
@@ -766,12 +768,12 @@ class TagsController < ApplicationController
|
||||
current_aliases.each do |alias_tag_name|
|
||||
next if alias_names.include?(alias_tag_name.name)
|
||||
|
||||
alias_tag_name.update!(canonical: nil)
|
||||
alias_tag_name.update!(canonical_id: nil)
|
||||
end
|
||||
|
||||
alias_names.each do |alias_name|
|
||||
alias_tag_name = TagName.find_or_create_by!(name: alias_name)
|
||||
alias_tag_name.update!(canonical: tag.tag_name)
|
||||
alias_tag_name.update!(canonical_id: tag.tag_name.id)
|
||||
end
|
||||
|
||||
affected_tags.compact.uniq.each do |affected_tag|
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする