コミットを比較
2 コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
| 4cd1104213 | |||
| 96b6ff3267 |
@@ -27,9 +27,8 @@ class PostVersionsController < ApplicationController
|
|||||||
'prev.original_created_before AS prev_original_created_before')
|
'prev.original_created_before AS prev_original_created_before')
|
||||||
q = q.where('post_versions.post_id = ?', post_id) if post_id
|
q = q.where('post_versions.post_id = ?', post_id) if post_id
|
||||||
if tag_id
|
if tag_id
|
||||||
q = q.where(("JSON_CONTAINS(post_versions.tags_json, JSON_OBJECT('id', :tag_id)) " +
|
q = q.where("JSON_CONTAINS(post_versions.tags_json, JSON_OBJECT('id', #{ tag_id })) " +
|
||||||
"OR JSON_CONTAINS(prev.tags_json, JSON_OBJECT('id', :tag_id))"),
|
"OR JSON_CONTAINS(prev.tags_json, JSON_OBJECT('id', #{ tag_id }))")
|
||||||
tag_id:)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
count = q.except(:select, :order, :limit, :offset).count
|
count = q.except(:select, :order, :limit, :offset).count
|
||||||
@@ -50,9 +49,43 @@ class PostVersionsController < ApplicationController
|
|||||||
rows.map do |row|
|
rows.map do |row|
|
||||||
cur_tags =
|
cur_tags =
|
||||||
normalise_json(row.tags_json)
|
normalise_json(row.tags_json)
|
||||||
|
.sort_by { [(case _1.fetch('category')
|
||||||
|
when 'deerjikist'
|
||||||
|
0
|
||||||
|
when 'meme'
|
||||||
|
1
|
||||||
|
when 'character'
|
||||||
|
2
|
||||||
|
when 'general'
|
||||||
|
3
|
||||||
|
when 'material'
|
||||||
|
4
|
||||||
|
when 'meta'
|
||||||
|
5
|
||||||
|
else
|
||||||
|
6
|
||||||
|
end),
|
||||||
|
_1.fetch('name').downcase] }
|
||||||
.map { Post.tag_snapshot_literal(_1) }
|
.map { Post.tag_snapshot_literal(_1) }
|
||||||
prev_tags =
|
prev_tags =
|
||||||
(normalise_json(row.attributes['prev_tags_json']) || [])
|
(normalise_json(row.attributes['prev_tags_json']) || [])
|
||||||
|
.sort_by { [(case _1.fetch('category')
|
||||||
|
when 'deerjikist'
|
||||||
|
0
|
||||||
|
when 'meme'
|
||||||
|
1
|
||||||
|
when 'character'
|
||||||
|
2
|
||||||
|
when 'general'
|
||||||
|
3
|
||||||
|
when 'material'
|
||||||
|
4
|
||||||
|
when 'meta'
|
||||||
|
5
|
||||||
|
else
|
||||||
|
6
|
||||||
|
end),
|
||||||
|
_1.fetch('name').downcase] }
|
||||||
.map { Post.tag_snapshot_literal(_1) }
|
.map { Post.tag_snapshot_literal(_1) }
|
||||||
|
|
||||||
{ post_id: row.post_id,
|
{ post_id: row.post_id,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ RSpec.describe PostVersion, type: :model do
|
|||||||
url: post_record.url,
|
url: post_record.url,
|
||||||
thumbnail_base: post_record.thumbnail_base,
|
thumbnail_base: post_record.thumbnail_base,
|
||||||
tags: post_record.snapshot_tag_names.join(' '),
|
tags: post_record.snapshot_tag_names.join(' '),
|
||||||
|
tags_json: post_record.snapshot_tags_json,
|
||||||
parent_post_ids: post_record.snapshot_parent_post_ids.join(' '),
|
parent_post_ids: post_record.snapshot_parent_post_ids.join(' '),
|
||||||
original_created_from: post_record.original_created_from,
|
original_created_from: post_record.original_created_from,
|
||||||
original_created_before: post_record.original_created_before,
|
original_created_before: post_record.original_created_before,
|
||||||
|
|||||||
@@ -333,6 +333,7 @@ RSpec.describe Tag, type: :model do
|
|||||||
url: post.url,
|
url: post.url,
|
||||||
thumbnail_base: post.thumbnail_base,
|
thumbnail_base: post.thumbnail_base,
|
||||||
tags: snapshot_tags(post),
|
tags: snapshot_tags(post),
|
||||||
|
tags_json: post.snapshot_tags_json,
|
||||||
parent_post_ids: post.snapshot_parent_post_ids.join(' '),
|
parent_post_ids: post.snapshot_parent_post_ids.join(' '),
|
||||||
original_created_from: post.original_created_from,
|
original_created_from: post.original_created_from,
|
||||||
original_created_before: post.original_created_before,
|
original_created_before: post.original_created_before,
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ RSpec.describe 'Posts API', type: :request do
|
|||||||
thumbnail_base: post.thumbnail_base,
|
thumbnail_base: post.thumbnail_base,
|
||||||
video_ms: post.video_ms,
|
video_ms: post.video_ms,
|
||||||
tags: post.snapshot_tag_names.join(' '),
|
tags: post.snapshot_tag_names.join(' '),
|
||||||
|
tags_json: post.snapshot_tags_json,
|
||||||
parent_post_ids: post.snapshot_parent_post_ids.join(' '),
|
parent_post_ids: post.snapshot_parent_post_ids.join(' '),
|
||||||
original_created_from: post.original_created_from,
|
original_created_from: post.original_created_from,
|
||||||
original_created_before: post.original_created_before,
|
original_created_before: post.original_created_before,
|
||||||
@@ -2024,6 +2025,7 @@ RSpec.describe 'Posts API', type: :request do
|
|||||||
url: post.url,
|
url: post.url,
|
||||||
thumbnail_base: post.thumbnail_base,
|
thumbnail_base: post.thumbnail_base,
|
||||||
tags: snapshot_tags(post),
|
tags: snapshot_tags(post),
|
||||||
|
tags_json: post.snapshot_tags_json,
|
||||||
parent_post_ids: post.snapshot_parent_post_ids.join(' '),
|
parent_post_ids: post.snapshot_parent_post_ids.join(' '),
|
||||||
original_created_from: post.original_created_from,
|
original_created_from: post.original_created_from,
|
||||||
original_created_before: post.original_created_before,
|
original_created_before: post.original_created_before,
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ RSpec.describe 'nico:sync' do
|
|||||||
url: post.url,
|
url: post.url,
|
||||||
thumbnail_base: post.thumbnail_base,
|
thumbnail_base: post.thumbnail_base,
|
||||||
tags: snapshot_tags(post),
|
tags: snapshot_tags(post),
|
||||||
|
tags_json: post.snapshot_tags_json,
|
||||||
parent_post_ids: post.snapshot_parent_post_ids.join(' '),
|
parent_post_ids: post.snapshot_parent_post_ids.join(' '),
|
||||||
original_created_from: post.original_created_from,
|
original_created_from: post.original_created_from,
|
||||||
original_created_before: post.original_created_before,
|
original_created_before: post.original_created_before,
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする