Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 933d952

Browse files
committed
DEV: Apply feedback from review
1 parent 43e2faf commit 933d952

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

app/controllers/discourse_ai/sentiment/sentiment_controller.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ module Sentiment
55
class SentimentController < ::Admin::StaffController
66
include Constants
77
requires_plugin ::DiscourseAi::PLUGIN_NAME
8-
requires_login
98

109
def posts
11-
group_by = params[:group_by]&.to_sym
12-
group_value = params[:group_value].presence
10+
group_by = params.required(:group_by)&.to_sym
11+
group_value = params.required(:group_value).presence
1312
start_date = params[:start_date].presence
1413
end_date = params[:end_date]
1514
threshold = SENTIMENT_THRESHOLD
1615

17-
if %i[category tag].exclude?(group_by) || group_value.blank?
18-
raise Discourse::InvalidParameters
19-
end
16+
raise Discourse::InvalidParameters if %i[category tag].exclude?(group_by)
2017

2118
case group_by
2219
when :category
@@ -26,8 +23,6 @@ def posts
2623
grouping_clause = "tags.name"
2724
grouping_join =
2825
"INNER JOIN topic_tags tt ON tt.topic_id = p.topic_id INNER JOIN tags ON tags.id = tt.tag_id"
29-
else
30-
raise Discourse::InvalidParameters
3126
end
3227

3328
posts =
@@ -59,6 +54,7 @@ def posts
5954
p.user_id > 0 AND
6055
cr.model_used = 'cardiffnlp/twitter-roberta-base-sentiment-latest' AND
6156
((:start_date IS NULL OR p.created_at > :start_date) AND (:end_date IS NULL OR p.created_at < :end_date))
57+
AND p.deleted_at IS NULL
6258
ORDER BY p.created_at DESC
6359
SQL
6460
group_value: group_value,

0 commit comments

Comments
 (0)