FEATURE: Add links to filtered emotion view on emotion dashboard table (#953)

This commit is contained in:
Rafael dos Santos Silva 2024-11-25 15:51:01 -03:00 committed by GitHub
parent 79021252e9
commit 6c25718a7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 14 deletions

View File

@ -6,14 +6,18 @@
</div> </div>
<div class="cell value today-count"> <div class="cell value today-count">
<a href={{this.todayLink}}>
{{number this.model.todayCount}} {{number this.model.todayCount}}
</a>
</div> </div>
<div <div
class="cell value yesterday-count {{this.model.yesterdayTrend}}" class="cell value yesterday-count {{this.model.yesterdayTrend}}"
title={{this.model.yesterdayCountTitle}} title={{this.model.yesterdayCountTitle}}
> >
<a href={{this.yesterdayLink}}>
{{number this.model.yesterdayCount}} {{number this.model.yesterdayCount}}
</a>
{{d-icon this.model.yesterdayTrendIcon}} {{d-icon this.model.yesterdayTrendIcon}}
</div> </div>
@ -21,7 +25,9 @@
class="cell value sevendays-count {{this.model.sevenDaysTrend}}" class="cell value sevendays-count {{this.model.sevenDaysTrend}}"
title={{this.model.sevenDaysCountTitle}} title={{this.model.sevenDaysCountTitle}}
> >
<a href={{this.lastSevenDaysLink}}>
{{number this.model.lastSevenDaysCount}} {{number this.model.lastSevenDaysCount}}
</a>
{{d-icon this.model.sevenDaysTrendIcon}} {{d-icon this.model.sevenDaysTrendIcon}}
</div> </div>
@ -29,7 +35,10 @@
class="cell value thirty-days-count {{this.model.thirtyDaysTrend}}" class="cell value thirty-days-count {{this.model.thirtyDaysTrend}}"
title={{this.model.thirtyDaysCountTitle}} title={{this.model.thirtyDaysCountTitle}}
> >
<a href={{this.lastThirtyDaysLink}}>
{{number this.model.lastThirtyDaysCount}} {{number this.model.lastThirtyDaysCount}}
</a>
{{#if this.model.canDisplayTrendIcon}} {{#if this.model.canDisplayTrendIcon}}
{{d-icon this.model.thirtyDaysTrendIcon}} {{d-icon this.model.thirtyDaysTrendIcon}}
{{/if}} {{/if}}

View File

@ -5,23 +5,35 @@ import getURL from "discourse-common/lib/get-url";
@classNames("admin-report-counters") @classNames("admin-report-counters")
@attributeBindings("model.description:title") @attributeBindings("model.description:title")
export default class AdminReportEmotion extends Component { export default class AdminReportEmotion extends Component {
get filterURL() { get todayLink() {
return getURL(`/filter?q=`); let date = moment().format("YYYY-MM-DD");
return this._filterURL(date);
} }
get today() { get yesterdayLink() {
return moment().format("YYYY-MM-DD"); let date = moment().subtract(1, "day").format("YYYY-MM-DD");
return this._filterURL(date);
} }
get yesterday() { get lastSevenDaysLink() {
return moment().subtract(1, "day").format("YYYY-MM-DD"); let date = moment().subtract(1, "week").format("YYYY-MM-DD");
return this._filterURL(date);
} }
get lastWeek() { get lastThirtyDaysLink() {
return moment().subtract(1, "week").format("YYYY-MM-DD"); let date = moment().subtract(1, "month").format("YYYY-MM-DD");
return this._filterURL(date);
} }
get lastMonth() { _baseFilter() {
return moment().subtract(1, "month").format("YYYY-MM-DD"); return "/filter?q=activity-after%3A";
}
_model() {
return "%20order%3A" + this.model.type;
}
_filterURL(date) {
return getURL(`${this._baseFilter()}${date}${this._model()}`);
} }
} }

View File

@ -12,4 +12,14 @@ RSpec.describe "Admin dashboard", type: :system do
expect(page).to have_css(".section.sentiment") expect(page).to have_css(".section.sentiment")
end end
xit "displays the emotion table with links" do
SiteSetting.ai_sentiment_enabled = true
sign_in(admin)
visit "/admin"
find(".navigation-item.sentiment").click()
expect(page).to have_css(".admin-report.emotion-love .cell.value.today-count a")
end
end end