diff --git a/assets/javascripts/discourse/components/admin-report-emotion.hbs b/assets/javascripts/discourse/components/admin-report-emotion.hbs index 6c0941e4..a546ef81 100644 --- a/assets/javascripts/discourse/components/admin-report-emotion.hbs +++ b/assets/javascripts/discourse/components/admin-report-emotion.hbs @@ -2,16 +2,26 @@ {{#if this.model.icon}} {{d-icon this.model.icon}} {{/if}} - {{this.model.title}} + {{this.model.title}} -
{{number this.model.todayCount}}
+
+ + {{number this.model.todayCount}} + +
- {{number this.model.yesterdayCount}} + + {{number this.model.yesterdayCount}} + {{d-icon this.model.yesterdayTrendIcon}}
@@ -19,7 +29,11 @@ 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}} @@ -27,7 +41,11 @@ 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}} diff --git a/assets/javascripts/discourse/components/admin-report-emotion.js b/assets/javascripts/discourse/components/admin-report-emotion.js index 724d2e22..221f7123 100644 --- a/assets/javascripts/discourse/components/admin-report-emotion.js +++ b/assets/javascripts/discourse/components/admin-report-emotion.js @@ -6,7 +6,22 @@ import getURL from "discourse-common/lib/get-url"; @attributeBindings("model.description:title") export default class AdminReportEmotion extends Component { get filterURL() { - let aMonthAgo = moment().subtract(1, "month").format("YYYY-MM-DD"); - return getURL(`/filter?q=activity-after%3A${aMonthAgo}%20order%3A`); + return getURL(`/filter?q=`); + } + + get today() { + return moment().format("YYYY-MM-DD"); + } + + get yesterday() { + return moment().subtract(1, "day").format("YYYY-MM-DD"); + } + + get lastWeek() { + return moment().subtract(1, "week").format("YYYY-MM-DD"); + } + + get lastMonth() { + return moment().subtract(1, "month").format("YYYY-MM-DD"); } } diff --git a/assets/javascripts/discourse/controllers/admin-dashboard-sentiment.js b/assets/javascripts/discourse/controllers/admin-dashboard-sentiment.js index dab63795..a74ef8ed 100644 --- a/assets/javascripts/discourse/controllers/admin-dashboard-sentiment.js +++ b/assets/javascripts/discourse/controllers/admin-dashboard-sentiment.js @@ -1,6 +1,12 @@ +import { computed } from "@ember/object"; import AdminDashboardTabController from "admin/controllers/admin-dashboard-tab"; export default class AdminDashboardSentiment extends AdminDashboardTabController { + @computed("startDate", "endDate") + get filters() { + return { startDate: this.startDate, endDate: this.endDate }; + } + get emotions() { const emotions = [ "admiration", diff --git a/lib/sentiment/emotion_dashboard_report.rb b/lib/sentiment/emotion_dashboard_report.rb index eb5ed94b..14763c53 100644 --- a/lib/sentiment/emotion_dashboard_report.rb +++ b/lib/sentiment/emotion_dashboard_report.rb @@ -9,7 +9,7 @@ module DiscourseAi 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).map { |row| { x: row.day, y: row.send(emotion) } } + query_results.take(30).reduce(0) { |sum, row| sum + row.send(emotion) }.to_i end end