This reverts commit 375dd702b2
.
This commit is contained in:
parent
375dd702b2
commit
700e9de073
|
@ -400,7 +400,9 @@ en:
|
|||
|
||||
sentiment:
|
||||
reports:
|
||||
overall_sentiment: "Overall sentiment (Positive - Negative)"
|
||||
overall_sentiment:
|
||||
positive: "Positive"
|
||||
negative: "Negative"
|
||||
post_emotion:
|
||||
sadness: "Sadness 😢"
|
||||
surprise: "Surprise 😱"
|
||||
|
|
|
@ -5,7 +5,7 @@ module DiscourseAi
|
|||
class SentimentDashboardReport
|
||||
def self.register!(plugin)
|
||||
plugin.add_report("overall_sentiment") do |report|
|
||||
report.modes = [:chart]
|
||||
report.modes = [:stacked_chart]
|
||||
threshold = 0.6
|
||||
|
||||
sentiment_count_sql = Proc.new { |sentiment| <<~SQL }
|
||||
|
@ -38,17 +38,20 @@ module DiscourseAi
|
|||
threshold: threshold,
|
||||
)
|
||||
|
||||
data_points = %w[positive negative]
|
||||
|
||||
return report if grouped_sentiments.empty?
|
||||
|
||||
report.data =
|
||||
grouped_sentiments.map do |gs|
|
||||
data_points.map do |point|
|
||||
{
|
||||
color: report.colors[:lime],
|
||||
label: I18n.t("discourse_ai.sentiment.reports.overall_sentiment"),
|
||||
data: {
|
||||
x: gs.posted_at,
|
||||
y: gs.public_send("positive_count") - gs.public_send("negative_count"),
|
||||
},
|
||||
req: "sentiment_#{point}",
|
||||
color: point == "positive" ? report.colors[:lime] : report.colors[:purple],
|
||||
label: I18n.t("discourse_ai.sentiment.reports.overall_sentiment.#{point}"),
|
||||
data:
|
||||
grouped_sentiments.map do |gs|
|
||||
{ x: gs.posted_at, y: gs.public_send("#{point}_count") }
|
||||
end,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -77,8 +77,11 @@ RSpec.describe DiscourseAi::Sentiment::EntryPoint do
|
|||
sentiment_classification(pm, positive_classification)
|
||||
|
||||
report = Report.find("overall_sentiment")
|
||||
overall_sentiment = report.data[0][:data][:y].to_i
|
||||
expect(overall_sentiment).to eq(2)
|
||||
positive_data_point = report.data[0][:data].first[:y].to_i
|
||||
negative_data_point = report.data[1][:data].first[:y].to_i
|
||||
|
||||
expect(positive_data_point).to eq(1)
|
||||
expect(negative_data_point).to eq(-1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue