mirror of https://github.com/LemmyNet/lemmy.git
Merge b7e8981d29
into 9120207314
commit
d9f214a3cc
|
@ -59,7 +59,6 @@ pub async fn like_comment(
|
||||||
|
|
||||||
let like_form = CommentLikeForm {
|
let like_form = CommentLikeForm {
|
||||||
comment_id: data.comment_id,
|
comment_id: data.comment_id,
|
||||||
post_id: orig_comment.post.id,
|
|
||||||
person_id: local_user_view.person.id,
|
person_id: local_user_view.person.id,
|
||||||
score: data.score,
|
score: data.score,
|
||||||
};
|
};
|
||||||
|
|
|
@ -169,7 +169,6 @@ pub async fn update_read_comments(
|
||||||
person_id,
|
person_id,
|
||||||
post_id,
|
post_id,
|
||||||
read_comments,
|
read_comments,
|
||||||
..PersonPostAggregatesForm::default()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PersonPostAggregates::upsert(pool, &person_post_agg_form)
|
PersonPostAggregates::upsert(pool, &person_post_agg_form)
|
||||||
|
|
|
@ -160,7 +160,6 @@ pub async fn create_comment(
|
||||||
// You like your own comment by default
|
// You like your own comment by default
|
||||||
let like_form = CommentLikeForm {
|
let like_form = CommentLikeForm {
|
||||||
comment_id: inserted_comment.id,
|
comment_id: inserted_comment.id,
|
||||||
post_id: post.id,
|
|
||||||
person_id: local_user_view.person.id,
|
person_id: local_user_view.person.id,
|
||||||
score: 1,
|
score: 1,
|
||||||
};
|
};
|
||||||
|
|
|
@ -160,7 +160,6 @@ impl ActivityHandler for CreateOrUpdateNote {
|
||||||
// author likes their own comment by default
|
// author likes their own comment by default
|
||||||
let like_form = CommentLikeForm {
|
let like_form = CommentLikeForm {
|
||||||
comment_id: comment.id,
|
comment_id: comment.id,
|
||||||
post_id: comment.post_id,
|
|
||||||
person_id: comment.creator_id,
|
person_id: comment.creator_id,
|
||||||
score: 1,
|
score: 1,
|
||||||
};
|
};
|
||||||
|
|
|
@ -62,7 +62,6 @@ async fn vote_comment(
|
||||||
let comment_id = comment.id;
|
let comment_id = comment.id;
|
||||||
let like_form = CommentLikeForm {
|
let like_form = CommentLikeForm {
|
||||||
comment_id,
|
comment_id,
|
||||||
post_id: comment.post_id,
|
|
||||||
person_id: actor.id,
|
person_id: actor.id,
|
||||||
score: vote_type.into(),
|
score: vote_type.into(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -110,7 +110,6 @@ mod tests {
|
||||||
|
|
||||||
let comment_like = CommentLikeForm {
|
let comment_like = CommentLikeForm {
|
||||||
comment_id: inserted_comment.id,
|
comment_id: inserted_comment.id,
|
||||||
post_id: inserted_post.id,
|
|
||||||
person_id: inserted_person.id,
|
person_id: inserted_person.id,
|
||||||
score: 1,
|
score: 1,
|
||||||
};
|
};
|
||||||
|
@ -129,7 +128,6 @@ mod tests {
|
||||||
// Add a post dislike from the other person
|
// Add a post dislike from the other person
|
||||||
let comment_dislike = CommentLikeForm {
|
let comment_dislike = CommentLikeForm {
|
||||||
comment_id: inserted_comment.id,
|
comment_id: inserted_comment.id,
|
||||||
post_id: inserted_post.id,
|
|
||||||
person_id: another_inserted_person.id,
|
person_id: another_inserted_person.id,
|
||||||
score: -1,
|
score: -1,
|
||||||
};
|
};
|
||||||
|
|
|
@ -93,7 +93,6 @@ mod tests {
|
||||||
let mut comment_like = CommentLikeForm {
|
let mut comment_like = CommentLikeForm {
|
||||||
comment_id: inserted_comment.id,
|
comment_id: inserted_comment.id,
|
||||||
person_id: inserted_person.id,
|
person_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
|
||||||
score: 1,
|
score: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -113,7 +112,6 @@ mod tests {
|
||||||
let child_comment_like = CommentLikeForm {
|
let child_comment_like = CommentLikeForm {
|
||||||
comment_id: inserted_child_comment.id,
|
comment_id: inserted_child_comment.id,
|
||||||
person_id: another_inserted_person.id,
|
person_id: another_inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
|
||||||
score: 1,
|
score: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,6 @@ pub struct PersonPostAggregatesForm {
|
||||||
pub person_id: PersonId,
|
pub person_id: PersonId,
|
||||||
pub post_id: PostId,
|
pub post_id: PostId,
|
||||||
pub read_comments: i64,
|
pub read_comments: i64,
|
||||||
pub published: Option<DateTime<Utc>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Copy, Hash)]
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Copy, Hash)]
|
||||||
|
|
|
@ -293,7 +293,6 @@ mod tests {
|
||||||
// Comment Like
|
// Comment Like
|
||||||
let comment_like_form = CommentLikeForm {
|
let comment_like_form = CommentLikeForm {
|
||||||
comment_id: inserted_comment.id,
|
comment_id: inserted_comment.id,
|
||||||
post_id: inserted_post.id,
|
|
||||||
person_id: inserted_person.id,
|
person_id: inserted_person.id,
|
||||||
score: 1,
|
score: 1,
|
||||||
};
|
};
|
||||||
|
@ -302,7 +301,6 @@ mod tests {
|
||||||
|
|
||||||
let expected_comment_like = CommentLike {
|
let expected_comment_like = CommentLike {
|
||||||
comment_id: inserted_comment.id,
|
comment_id: inserted_comment.id,
|
||||||
post_id: inserted_post.id,
|
|
||||||
person_id: inserted_person.id,
|
person_id: inserted_person.id,
|
||||||
published: inserted_comment_like.published,
|
published: inserted_comment_like.published,
|
||||||
score: 1,
|
score: 1,
|
||||||
|
|
|
@ -99,7 +99,6 @@ pub struct CommentUpdateForm {
|
||||||
pub struct CommentLike {
|
pub struct CommentLike {
|
||||||
pub person_id: PersonId,
|
pub person_id: PersonId,
|
||||||
pub comment_id: CommentId,
|
pub comment_id: CommentId,
|
||||||
pub post_id: PostId, // TODO this is redundant
|
|
||||||
pub score: i16,
|
pub score: i16,
|
||||||
pub published: DateTime<Utc>,
|
pub published: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
@ -110,7 +109,6 @@ pub struct CommentLike {
|
||||||
pub struct CommentLikeForm {
|
pub struct CommentLikeForm {
|
||||||
pub person_id: PersonId,
|
pub person_id: PersonId,
|
||||||
pub comment_id: CommentId,
|
pub comment_id: CommentId,
|
||||||
pub post_id: PostId, // TODO this is redundant
|
|
||||||
pub score: i16,
|
pub score: i16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -604,7 +604,6 @@ mod tests {
|
||||||
|
|
||||||
let comment_like_form = CommentLikeForm {
|
let comment_like_form = CommentLikeForm {
|
||||||
comment_id: inserted_comment_0.id,
|
comment_id: inserted_comment_0.id,
|
||||||
post_id: inserted_post.id,
|
|
||||||
person_id: inserted_timmy_person.id,
|
person_id: inserted_timmy_person.id,
|
||||||
score: 1,
|
score: 1,
|
||||||
};
|
};
|
||||||
|
@ -704,7 +703,6 @@ mod tests {
|
||||||
// Like a new comment
|
// Like a new comment
|
||||||
let comment_like_form = CommentLikeForm {
|
let comment_like_form = CommentLikeForm {
|
||||||
comment_id: data.inserted_comment_1.id,
|
comment_id: data.inserted_comment_1.id,
|
||||||
post_id: data.inserted_post.id,
|
|
||||||
person_id: data.timmy_local_user_view.person.id,
|
person_id: data.timmy_local_user_view.person.id,
|
||||||
score: 1,
|
score: 1,
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@ use diesel::{
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
newtypes::{CommentId, PostId},
|
newtypes::{CommentId, PostId},
|
||||||
schema::{comment_like, community_person_ban, person, post, post_like},
|
schema::{comment, comment_like, community_person_ban, person, post, post_like},
|
||||||
utils::{get_conn, limit_and_offset, DbPool},
|
utils::{get_conn, limit_and_offset, DbPool},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ impl VoteView {
|
||||||
|
|
||||||
comment_like::table
|
comment_like::table
|
||||||
.inner_join(person::table)
|
.inner_join(person::table)
|
||||||
.inner_join(post::table)
|
.inner_join(comment::table.inner_join(post::table))
|
||||||
// Join to community_person_ban to get creator_banned_from_community
|
// Join to community_person_ban to get creator_banned_from_community
|
||||||
.left_join(
|
.left_join(
|
||||||
community_person_ban::table.on(
|
community_person_ban::table.on(
|
||||||
|
@ -181,7 +181,6 @@ mod tests {
|
||||||
|
|
||||||
// Timothy votes down his own comment
|
// Timothy votes down his own comment
|
||||||
let timmy_comment_vote_form = CommentLikeForm {
|
let timmy_comment_vote_form = CommentLikeForm {
|
||||||
post_id: inserted_post.id,
|
|
||||||
comment_id: inserted_comment.id,
|
comment_id: inserted_comment.id,
|
||||||
person_id: inserted_timmy.id,
|
person_id: inserted_timmy.id,
|
||||||
score: -1,
|
score: -1,
|
||||||
|
@ -192,7 +191,6 @@ mod tests {
|
||||||
|
|
||||||
// Sara upvotes timmy's comment
|
// Sara upvotes timmy's comment
|
||||||
let sara_comment_vote_form = CommentLikeForm {
|
let sara_comment_vote_form = CommentLikeForm {
|
||||||
post_id: inserted_post.id,
|
|
||||||
comment_id: inserted_comment.id,
|
comment_id: inserted_comment.id,
|
||||||
person_id: inserted_sara.id,
|
person_id: inserted_sara.id,
|
||||||
score: 1,
|
score: 1,
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
ALTER TABLE comment_actions
|
||||||
|
ADD COLUMN post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE;
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
comment_actions
|
||||||
|
SET
|
||||||
|
post_id = (
|
||||||
|
SELECT
|
||||||
|
post_id
|
||||||
|
FROM
|
||||||
|
comment
|
||||||
|
WHERE
|
||||||
|
comment.id = comment_actions.comment_id)
|
||||||
|
WHERE
|
||||||
|
liked IS NOT NULL;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
ALTER TABLE comment_actions
|
||||||
|
DROP COLUMN post_id;
|
||||||
|
|
Loading…
Reference in New Issue