Skip to content

Commit 444fa0c

Browse files
committed
fix vote analytics date filter for comments
1 parent 0b81df2 commit 444fa0c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

crates/db_views_actor/src/vote_analytics_given_by_view.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,24 @@ impl VoteAnalyticsGivenByPersonView {
141141
// parameter used in the statements below without leaving any space. It could probably be
142142
// improved by implementing QueryFragments.
143143
let mut sql_dynamic_parameter_binding_index = 3u8;
144-
let sql_since = start_time
144+
let (sql_since_post, sql_since_comment) = start_time
145145
.map(|_| {
146-
let s = format!("AND post_like.published >= ${sql_dynamic_parameter_binding_index}");
146+
let (s_post, s_comment) = (
147+
format!("AND post_like.published >= ${sql_dynamic_parameter_binding_index}"),
148+
format!("AND comment_like.published >= ${sql_dynamic_parameter_binding_index}"),
149+
);
147150
sql_dynamic_parameter_binding_index += 1;
148-
s
151+
(s_post, s_comment)
149152
})
150153
.unwrap_or_default();
151-
let sql_until = end_time
154+
let (sql_until_post, sql_until_comment) = end_time
152155
.map(|_| {
153-
let s = format!("AND post_like.published <= ${sql_dynamic_parameter_binding_index}");
156+
let (s_post, s_comment) = (
157+
format!("AND post_like.published <= ${sql_dynamic_parameter_binding_index}"),
158+
format!("AND comment_like.published <= ${sql_dynamic_parameter_binding_index}"),
159+
);
154160
sql_dynamic_parameter_binding_index += 1;
155-
s
161+
(s_post, s_comment)
156162
})
157163
.unwrap_or_default();
158164

@@ -214,8 +220,8 @@ UNION ALL
214220
SELECT * FROM post_likes_by_community
215221
"#,
216222
exclude_own = sql_exclude_own,
217-
since = sql_since,
218-
until = sql_until,
223+
since = sql_since_post,
224+
until = sql_until_post,
219225
)).into_boxed()
220226
.bind::<Integer, _>(&person_id.0)
221227
.bind::<BigInt, _>(limit);
@@ -288,8 +294,8 @@ UNION ALL
288294
SELECT * FROM comment_likes_by_community
289295
"#,
290296
exclude_own = sql_exclude_own,
291-
since = sql_since,
292-
until = sql_until,
297+
since = sql_since_comment,
298+
until = sql_until_comment,
293299
)).into_boxed()
294300
.bind::<Integer, _>(&person_id.0)
295301
.bind::<BigInt, _>(limit);

0 commit comments

Comments
 (0)