Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions assets/javascripts/discourse/components/admin-report-emotion.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,50 @@
{{#if this.model.icon}}
{{d-icon this.model.icon}}
{{/if}}
<a href="{{this.filterURL}}{{this.model.type}}">{{this.model.title}}</a>
{{this.model.title}}
</div>

<div class="cell value today-count">{{number this.model.todayCount}}</div>
<div class="cell value today-count">
<a
href="{{this.filterURL}}activity-after%3A{{this.today}}%20order%3A{{this.model.type}}"
>
{{number this.model.todayCount}}
</a>
</div>

<div
class="cell value yesterday-count {{this.model.yesterdayTrend}}"
title={{this.model.yesterdayCountTitle}}
>
{{number this.model.yesterdayCount}}
<a
href="{{this.filterURL}}activity-after%3A{{this.yesterday}}%20order%3A{{this.model.type}}"
>
{{number this.model.yesterdayCount}}
</a>
{{d-icon this.model.yesterdayTrendIcon}}
</div>

<div
class="cell value sevendays-count {{this.model.sevenDaysTrend}}"
title={{this.model.sevenDaysCountTitle}}
>
{{number this.model.lastSevenDaysCount}}
<a
href="{{this.filterURL}}activity-after%3A{{this.lastWeek}}%20order%3A{{this.model.type}}"
>
{{number this.model.lastSevenDaysCount}}
</a>
{{d-icon this.model.sevenDaysTrendIcon}}
</div>

<div
class="cell value thirty-days-count {{this.model.thirtyDaysTrend}}"
title={{this.model.thirtyDaysCountTitle}}
>
{{number this.model.lastThirtyDaysCount}}
<a
href="{{this.filterURL}}activity-after%3A{{this.lastMonth}}%20order%3A{{this.model.type}}"
>
{{number this.model.lastThirtyDaysCount}}
</a>

{{#if this.model.canDisplayTrendIcon}}
{{d-icon this.model.thirtyDaysTrendIcon}}
Expand Down
19 changes: 17 additions & 2 deletions assets/javascripts/discourse/components/admin-report-emotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/sentiment/emotion_dashboard_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.register!(plugin)
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

Expand Down