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

Commit 700e9de

Browse files
authored
Revert "UX: Make sentiment trends more readable in time series data (#1013)" (#1016)
This reverts commit 375dd70.
1 parent 375dd70 commit 700e9de

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

config/locales/server.en.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ en:
400400

401401
sentiment:
402402
reports:
403-
overall_sentiment: "Overall sentiment (Positive - Negative)"
403+
overall_sentiment:
404+
positive: "Positive"
405+
negative: "Negative"
404406
post_emotion:
405407
sadness: "Sadness 😢"
406408
surprise: "Surprise 😱"

lib/sentiment/sentiment_dashboard_report.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Sentiment
55
class SentimentDashboardReport
66
def self.register!(plugin)
77
plugin.add_report("overall_sentiment") do |report|
8-
report.modes = [:chart]
8+
report.modes = [:stacked_chart]
99
threshold = 0.6
1010

1111
sentiment_count_sql = Proc.new { |sentiment| <<~SQL }
@@ -38,17 +38,20 @@ def self.register!(plugin)
3838
threshold: threshold,
3939
)
4040

41+
data_points = %w[positive negative]
42+
4143
return report if grouped_sentiments.empty?
4244

4345
report.data =
44-
grouped_sentiments.map do |gs|
46+
data_points.map do |point|
4547
{
46-
color: report.colors[:lime],
47-
label: I18n.t("discourse_ai.sentiment.reports.overall_sentiment"),
48-
data: {
49-
x: gs.posted_at,
50-
y: gs.public_send("positive_count") - gs.public_send("negative_count"),
51-
},
48+
req: "sentiment_#{point}",
49+
color: point == "positive" ? report.colors[:lime] : report.colors[:purple],
50+
label: I18n.t("discourse_ai.sentiment.reports.overall_sentiment.#{point}"),
51+
data:
52+
grouped_sentiments.map do |gs|
53+
{ x: gs.posted_at, y: gs.public_send("#{point}_count") }
54+
end,
5255
}
5356
end
5457
end

spec/lib/modules/sentiment/entry_point_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ def sentiment_classification(post, classification)
7777
sentiment_classification(pm, positive_classification)
7878

7979
report = Report.find("overall_sentiment")
80-
overall_sentiment = report.data[0][:data][:y].to_i
81-
expect(overall_sentiment).to eq(2)
80+
positive_data_point = report.data[0][:data].first[:y].to_i
81+
negative_data_point = report.data[1][:data].first[:y].to_i
82+
83+
expect(positive_data_point).to eq(1)
84+
expect(negative_data_point).to eq(-1)
8285
end
8386
end
8487

0 commit comments

Comments
 (0)