add current context for reports

This commit is contained in:
eiknat 2020-10-24 23:24:50 -04:00 committed by eiknat
parent 2cd2a4df45
commit 070efe72af
3 changed files with 14 additions and 2 deletions

View file

@ -15,6 +15,7 @@ table! {
published -> Timestamp, published -> Timestamp,
updated -> Nullable<Timestamp>, updated -> Nullable<Timestamp>,
post_id -> Int4, post_id -> Int4,
current_comment_text -> Text,
community_id -> Int4, community_id -> Int4,
creator_name -> Varchar, creator_name -> Varchar,
comment_creator_id -> Int4, comment_creator_id -> Int4,
@ -91,6 +92,7 @@ pub struct CommentReportView {
pub published: chrono::NaiveDateTime, pub published: chrono::NaiveDateTime,
pub updated: Option<chrono::NaiveDateTime>, pub updated: Option<chrono::NaiveDateTime>,
pub post_id: i32, pub post_id: i32,
pub current_comment_text: String,
pub community_id: i32, pub community_id: i32,
pub creator_name: String, pub creator_name: String,
pub comment_creator_id: i32, pub comment_creator_id: i32,

View file

@ -16,6 +16,9 @@ table! {
resolver_id -> Nullable<Int4>, resolver_id -> Nullable<Int4>,
published -> Timestamp, published -> Timestamp,
updated -> Nullable<Timestamp>, updated -> Nullable<Timestamp>,
current_post_name -> Varchar,
current_post_url -> Nullable<Text>,
current_post_body -> Nullable<Text>,
community_id -> Int4, community_id -> Int4,
creator_name -> Varchar, creator_name -> Varchar,
post_creator_id -> Int4, post_creator_id -> Int4,
@ -97,6 +100,9 @@ pub struct PostReportView {
pub resolver_id: Option<i32>, pub resolver_id: Option<i32>,
pub published: chrono::NaiveDateTime, pub published: chrono::NaiveDateTime,
pub updated: Option<chrono::NaiveDateTime>, pub updated: Option<chrono::NaiveDateTime>,
pub current_post_name: String,
pub current_post_url: Option<String>,
pub current_post_body: Option<String>,
pub community_id: i32, pub community_id: i32,
pub creator_name: String, pub creator_name: String,
pub post_creator_id: i32, pub post_creator_id: i32,

View file

@ -5,7 +5,7 @@ create table comment_report (
comment_text text not null, comment_text text not null,
reason text not null, reason text not null,
resolved bool not null default false, resolved bool not null default false,
resolver_id int references user_ on update cascade on delete cascade not null, -- user resolving report resolver_id int references user_ on update cascade on delete cascade, -- user resolving report
published timestamp not null default now(), published timestamp not null default now(),
updated timestamp null, updated timestamp null,
unique(comment_id, creator_id) -- users should only be able to report a comment once unique(comment_id, creator_id) -- users should only be able to report a comment once
@ -20,7 +20,7 @@ create table post_report (
post_body text, post_body text,
reason text not null, reason text not null,
resolved bool not null default false, resolved bool not null default false,
resolver_id int references user_ on update cascade on delete cascade not null, -- user resolving report resolver_id int references user_ on update cascade on delete cascade, -- user resolving report
published timestamp not null default now(), published timestamp not null default now(),
updated timestamp null, updated timestamp null,
unique(post_id, creator_id) -- users should only be able to report a post once unique(post_id, creator_id) -- users should only be able to report a post once
@ -29,6 +29,7 @@ create table post_report (
create or replace view comment_report_view as create or replace view comment_report_view as
select cr.*, select cr.*,
c.post_id, c.post_id,
c.content as current_comment_text,
p.community_id, p.community_id,
f.name as creator_name, f.name as creator_name,
u.id as comment_creator_id, u.id as comment_creator_id,
@ -41,6 +42,9 @@ left join user_ f on f.id = cr.creator_id;
create or replace view post_report_view as create or replace view post_report_view as
select pr.*, select pr.*,
p.name as current_post_name,
p.url as current_post_url,
p.body as current_post_body,
p.community_id, p.community_id,
f.name as creator_name, f.name as creator_name,
u.id as post_creator_id, u.id as post_creator_id,