diff --git a/assets/javascripts/discourse/components/admin-report-emotion.hbs b/assets/javascripts/discourse/components/admin-report-emotion.hbs
index a546ef81..fb0119bd 100644
--- a/assets/javascripts/discourse/components/admin-report-emotion.hbs
+++ b/assets/javascripts/discourse/components/admin-report-emotion.hbs
@@ -6,22 +6,14 @@
@@ -29,11 +21,7 @@
class="cell value sevendays-count {{this.model.sevenDaysTrend}}"
title={{this.model.sevenDaysCountTitle}}
>
-
- {{number this.model.lastSevenDaysCount}}
-
+ {{number this.model.lastSevenDaysCount}}
{{d-icon this.model.sevenDaysTrendIcon}}
@@ -41,12 +29,7 @@
class="cell value thirty-days-count {{this.model.thirtyDaysTrend}}"
title={{this.model.thirtyDaysCountTitle}}
>
-
- {{number this.model.lastThirtyDaysCount}}
-
-
+ {{number this.model.lastThirtyDaysCount}}
{{#if this.model.canDisplayTrendIcon}}
{{d-icon this.model.thirtyDaysTrendIcon}}
{{/if}}
diff --git a/assets/javascripts/discourse/controllers/admin-dashboard-sentiment.js b/assets/javascripts/discourse/controllers/admin-dashboard-sentiment.js
index a74ef8ed..824daf24 100644
--- a/assets/javascripts/discourse/controllers/admin-dashboard-sentiment.js
+++ b/assets/javascripts/discourse/controllers/admin-dashboard-sentiment.js
@@ -7,6 +7,13 @@ export default class AdminDashboardSentiment extends AdminDashboardTabController
return { startDate: this.startDate, endDate: this.endDate };
}
+ get emotionFilters() {
+ return {
+ startDate: moment().format("YYYY-MM-DD"),
+ endDate: moment().subtract(2, "month").format("YYYY-MM-DD"),
+ };
+ }
+
get emotions() {
const emotions = [
"admiration",
diff --git a/assets/javascripts/discourse/templates/admin-dashboard-sentiment.hbs b/assets/javascripts/discourse/templates/admin-dashboard-sentiment.hbs
index 5d20c19f..0e2310d8 100644
--- a/assets/javascripts/discourse/templates/admin-dashboard-sentiment.hbs
+++ b/assets/javascripts/discourse/templates/admin-dashboard-sentiment.hbs
@@ -60,6 +60,7 @@
{{#each this.emotions as |metric|}}
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 37a2fe46..0c717649 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -117,60 +117,88 @@ en:
yaxis: "Date"
emotion_admiration:
title: ðĪĐ Admiration
+ description: "Posts classified with the emotion admiration via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_amusement:
title: ð Amusement
+ description: "Posts classified with the emotion amusement via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_anger:
title: ð Anger
+ description: "Posts classified with the emotion anger via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_annoyance:
title: ð Annoyance
+ description: "Posts classified with the emotion annoyance via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_approval:
title: ð Approval
+ description: "Posts classified with the emotion approval via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_caring:
title: ðĪ Caring
+ description: "Posts classified with the emotion caring via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_confusion:
title: ð Confusion
+ description: "Posts classified with the emotion confusion via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_curiosity:
title: ðĪ Curiosity
+ description: "Posts classified with the emotion curiosity via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_desire:
title: ð Desire
+ description: "Posts classified with the emotion desire via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_disappointment:
title: ð Disappointment
+ description: "Posts classified with the emotion disappointment via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_disapproval:
title: ð Disapproval
+ description: "Posts classified with the emotion disapproval via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_disgust:
title: ðĪĒ Disgust
+ description: "Posts classified with the emotion disgust via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_embarrassment:
title: ðģ Embarrassment
+ description: "Posts classified with the emotion embarrassment via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_excitement:
title: ðĪŠ Excitement
+ description: "Posts classified with the emotion excitement via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_fear:
title: ðĻ Fear
+ description: "Posts classified with the emotion fear via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_gratitude:
title: ð Gratitude
+ description: "Posts classified with the emotion gratitude via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_grief:
title: ðĒ Grief
+ description: "Posts classified with the emotion grief via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_joy:
title: ð Joy
+ description: "Posts classified with the emotion joy via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_love:
title: âĪïļ Love
+ description: "Posts classified with the emotion love via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_nervousness:
title: ð° Nervousness
+ description: "Posts classified with the emotion nervousness via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_neutral:
title: ð Neutral
+ description: "Posts classified with the emotion neutral via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_optimism:
title: ð Optimism
+ description: "Posts classified with the emotion optimism via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_pride:
title: ðĶ Pride
+ description: "Posts classified with the emotion pride via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_realization:
title: ðĄ Realization
+ description: "Posts classified with the emotion realization via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_relief:
title: ð Relief
+ description: "Posts classified with the emotion relief via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_remorse:
title: ð Remorse
+ description: "Posts classified with the emotion remorse via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_sadness:
title: ð Sadness
+ description: "Posts classified with the emotion sadness via AI, using the model 'SamLowe/roberta-base-go_emotions'."
emotion_surprise:
title: ðē Surprise
+ description: "Posts classified with the emotion surprise via AI, using the model 'SamLowe/roberta-base-go_emotions'."
discourse_ai:
ai_artifact:
diff --git a/lib/sentiment/emotion_dashboard_report.rb b/lib/sentiment/emotion_dashboard_report.rb
index 14763c53..11c190c5 100644
--- a/lib/sentiment/emotion_dashboard_report.rb
+++ b/lib/sentiment/emotion_dashboard_report.rb
@@ -6,15 +6,16 @@ module DiscourseAi
def self.register!(plugin)
Emotions::LIST.each do |emotion|
plugin.add_report("emotion_#{emotion}") do |report|
- query_results = DiscourseAi::Sentiment::EmotionDashboardReport.fetch_data
- report.data = query_results.pop(30).map { |row| { x: row.day, y: row.send(emotion) } }
- report.prev30Days =
- query_results.take(30).reduce(0) { |sum, row| sum + row.send(emotion) }.to_i
+ query_results = DiscourseAi::Sentiment::EmotionDashboardReport.fetch_data(report)
+ report.data = query_results.map { |row| { x: row.day, y: row.send(emotion) } }
+ if report.facets.include?(:prev_period) && query_results.length > 30
+ report.prev30Days = query_results[31..60].sum { |row| row.send(emotion) }
+ end
end
end
- def self.fetch_data
- DB.query(<<~SQL, end: Time.now.tomorrow.midnight, start: 60.days.ago.midnight)
+ def self.fetch_data(report)
+ DB.query(<<~SQL, end: report.end_date, start: report.start_date)
SELECT
posts.created_at::DATE AS day,
#{