@@ -115,7 +115,6 @@ impl VoteAnalyticsGivenByPersonView {
115115 pub async fn read (
116116 pool : & mut DbPool < ' _ > ,
117117 person_id : PersonId ,
118- exclude_votes_on_self : bool ,
119118 start_time : Option < DateTime < Utc > > ,
120119 end_time : Option < DateTime < Utc > > ,
121120 limit : Option < i64 > ,
@@ -132,11 +131,6 @@ impl VoteAnalyticsGivenByPersonView {
132131
133132 let limit = fetch_limit ( limit) ?;
134133
135- let sql_exclude_own = match exclude_votes_on_self {
136- true => "AND creator.id != voter.id" ,
137- false => "" ,
138- } ;
139-
140134 // This is a rather dangerous workaround; this number must be one above than the highest
141135 // parameter used in the statements below without leaving any space. It could probably be
142136 // improved by implementing QueryFragments.
@@ -175,7 +169,7 @@ WITH post_likes_by_voter AS (
175169 JOIN community ON community.id = post.community_id
176170 WHERE voter.id = $1
177171 AND post_like.score != 0
178- {exclude_own}
172+ AND creator.id != voter.id
179173 {since}
180174 {until}
181175), post_likes_by_recipient AS (
@@ -219,7 +213,6 @@ SELECT * FROM post_likes_by_recipient
219213UNION ALL
220214SELECT * FROM post_likes_by_community
221215 "# ,
222- exclude_own = sql_exclude_own,
223216 since = sql_since_post,
224217 until = sql_until_post,
225218 ) ) . into_boxed ( )
@@ -249,7 +242,7 @@ WITH comment_likes_by_voter AS (
249242 JOIN community ON community.id = post.community_id
250243 WHERE voter.id = $1
251244 AND comment_like.score != 0
252- {exclude_own}
245+ AND creator.id != voter.id
253246 {since}
254247 {until}
255248), comment_likes_by_recipient AS (
@@ -293,7 +286,6 @@ SELECT * FROM comment_likes_by_recipient
293286UNION ALL
294287SELECT * FROM comment_likes_by_community
295288 "# ,
296- exclude_own = sql_exclude_own,
297289 since = sql_since_comment,
298290 until = sql_until_comment,
299291 ) ) . into_boxed ( )
@@ -488,23 +480,22 @@ mod test {
488480 // Test for non-existing person
489481 let invalid_person_id = PersonId ( -1 ) ;
490482 let view =
491- VoteAnalyticsGivenByPersonView :: read ( pool, invalid_person_id, false , None , None , None ) . await ;
483+ VoteAnalyticsGivenByPersonView :: read ( pool, invalid_person_id, None , None , None ) . await ;
492484 assert ! (
493485 view. is_err_and( |e| e == Error :: NotFound ) ,
494486 "query should not match a person" ,
495487 ) ;
496488
497489 // alice exists but hasn't voted on anything
498- let view =
499- VoteAnalyticsGivenByPersonView :: read ( pool, alice. id , false , None , None , None ) . await ?;
490+ let view = VoteAnalyticsGivenByPersonView :: read ( pool, alice. id , None , None , None ) . await ?;
500491 assert_eq ! ( 0 , view. post_votes_total_votes) ;
501492 assert_eq ! ( 0 , view. post_votes_total_upvotes) ;
502493 assert_eq ! ( 0 , view. post_votes_total_downvotes) ;
503494 assert_eq ! ( 0.0 , view. post_votes_total_upvote_percentage) ;
504495 assert_length ! ( 0 , view. post_votes_by_target_user) ;
505496 assert_length ! ( 0 , view. post_votes_by_target_community) ;
506497
507- let view = VoteAnalyticsGivenByPersonView :: read ( pool, bob. id , true , None , None , None ) . await ?;
498+ let view = VoteAnalyticsGivenByPersonView :: read ( pool, bob. id , None , None , None ) . await ?;
508499
509500 assert_eq ! ( 8 , view. post_votes_total_votes) ;
510501 assert_eq ! ( 3 , view. post_votes_total_upvotes) ;
0 commit comments