post events: show post-related mod actions on post event page.

Show the following actions on the post events page:

* Post bans and unbans
* Post deletions and undeletions
* Thumbnail regenerations and IQDB regenerations
* Favorites moves
* Rating locks and unlocks
* Note locks and unlocks

Fixes #3825: Events/Moderation page for each post should show eventual ban actions
This commit is contained in:
evazion
2022-09-26 03:24:50 -05:00
parent 75a2814f18
commit 67c992bfbf
8 changed files with 138 additions and 7 deletions

View File

@@ -0,0 +1,5 @@
class UpdatePostEventsToVersion2 < ActiveRecord::Migration[7.0]
def change
replace_view :post_events, version: 2, revert_to_version: 1
end
end

View File

@@ -1513,7 +1513,16 @@ UNION ALL
post_replacements.post_id,
post_replacements.creator_id,
post_replacements.created_at AS event_at
FROM public.post_replacements;
FROM public.post_replacements
UNION ALL
( SELECT 'ModAction'::character varying AS model_type,
mod_actions.id AS model_id,
mod_actions.subject_id AS post_id,
mod_actions.creator_id,
mod_actions.created_at AS event_at
FROM public.mod_actions
WHERE ((mod_actions.subject_type)::text = 'Post'::text)
ORDER BY mod_actions.created_at DESC);
--
@@ -6739,6 +6748,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220922014326'),
('20220923010905'),
('20220924092056'),
('20220925045236');
('20220925045236'),
('20220926050108');

View File

@@ -0,0 +1,23 @@
SELECT 'Post'::character varying AS model_type, id AS model_id, id AS post_id, uploader_id AS creator_id, created_at AS event_at
FROM posts
UNION ALL
SELECT 'PostAppeal'::character varying, id, post_id, creator_id, created_at
FROM post_appeals
UNION ALL
SELECT 'PostApproval'::character varying, id, post_id, user_id, created_at
FROM post_approvals
UNION ALL
SELECT 'PostDisapproval'::character varying, id, post_id, user_id, created_at
FROM post_disapprovals
UNION ALL
SELECT 'PostFlag'::character varying, id, post_id, creator_id, created_at
FROM post_flags
UNION ALL
SELECT 'PostReplacement'::character varying, id, post_id, creator_id, created_at
FROM post_replacements
UNION ALL (
SELECT 'ModAction'::character varying, id, subject_id, creator_id, created_at
FROM mod_actions
WHERE mod_actions.subject_type = 'Post'
ORDER BY created_at DESC
)