Skip to content

A platform for community discussion. Free, open, simple.

UX: Update section headlines and summaries for new admin dashboard (#42563)

Alan Guo Xiang Tanf86f20060195
diff --git a/app/services/admin_dashboard_engagement.rb b/app/services/admin_dashboard_engagement.rb
index ac83b8047c7..9cde44037e6 100644
--- a/app/services/admin_dashboard_engagement.rb
+++ b/app/services/admin_dashboard_engagement.rb
@@ -22,10 +22,8 @@ class AdminDashboardEngagement
end
def build
- kpis = build_kpis
{
- kpis: kpis,
- headline: build_headline(kpis),
+ kpis: build_kpis,
trust_level_pipeline: build_trust_level_pipeline,
posters: build_posters,
activity_by_category: build_activity_by_category,
@@ -47,47 +45,6 @@ class AdminDashboardEngagement
KPI_REPORTS.filter_map { |type, report| build_kpi(type, report) }
end
- HEADLINE_KEYS = {
- healthy_growth: "admin.dashboard.sections.engagement.headline.healthy_growth",
- declining: "admin.dashboard.sections.engagement.headline.declining",
- engaged_but_shrinking: "admin.dashboard.sections.engagement.headline.engaged_but_shrinking",
- growing_but_distracted: "admin.dashboard.sections.engagement.headline.growing_but_distracted",
- mixed: "admin.dashboard.sections.engagement.headline.mixed",
- no_signal: "admin.dashboard.sections.engagement.headline.no_signal",
- }.freeze
-
- def build_headline(kpis)
- stickiness = sign_of(kpi_change(kpis, :dau_mau))
- signups = sign_of(kpi_change(kpis, :new_signups))
- engaged = sign_of(kpi_change(kpis, :daily_engaged_users))
-
- key =
- if [stickiness, signups, engaged].all?(&:zero?)
- :no_signal
- elsif stickiness >= 0 && signups >= 0 && engaged >= 0
- :healthy_growth
- elsif stickiness <= 0 && signups <= 0 && engaged <= 0
- :declining
- elsif stickiness >= 0 && (signups < 0 || engaged < 0)
- :engaged_but_shrinking
- elsif stickiness < 0 && signups > 0
- :growing_but_distracted
- else
- :mixed
- end
-
- { key: HEADLINE_KEYS[key] }
- end
-
- def kpi_change(kpis, type)
- kpis.find { |k| k[:type] == type }&.dig(:percent_change)
- end
-
- def sign_of(value)
- return 0 if value.nil? || value.zero?
- value.positive? ? 1 : -1
- end
-
def build_trust_level_pipeline
args = { start_date: start_date, end_date: end_date }
diff --git a/app/services/admin_dashboard_search.rb b/app/services/admin_dashboard_search.rb
index 76390d7553f..f444e4b5343 100644
--- a/app/services/admin_dashboard_search.rb
+++ b/app/services/admin_dashboard_search.rb
@@ -40,7 +40,6 @@ class AdminDashboardSearch
{
logging_enabled: true,
- headline_state: headline_state(current: current, kpis: kpis),
kpis: kpis,
trending: trending,
trending_period: trending_period,
@@ -60,7 +59,7 @@ class AdminDashboardSearch
end
def total_searches_kpi(current:, prior:)
- kpi = { value: current[:total] }
+ kpi = { value: current[:total], previous_value: prior[:total] }
if current[:total].positive? && prior[:total].positive?
change = formatted_change((current[:total] - prior[:total]) * 100.0 / prior[:total])
@@ -71,10 +70,14 @@ class AdminDashboardSearch
end
def no_result_rate_kpi(current:, prior:)
- return { value: nil, exceeds_threshold: false } if current[:total].zero?
+ previous_value = no_result_rate(prior).round if prior[:total].positive?
+ if current[:total].zero?
+ return { value: nil, previous_value: previous_value, exceeds_threshold: false }
+ end
kpi = {
value: no_result_rate(current).round,
+ previous_value: previous_value,
exceeds_threshold: current[:no_match] * 100 > current[:total] * ALARM_THRESHOLD_PERCENT,
}
@@ -95,15 +98,6 @@ class AdminDashboardSearch
rounded.zero? ? nil : rounded
end
- def headline_state(current:, kpis:)
- return "no_signal" if current[:total].zero?
- return "content_gaps" if kpis[:no_result_rate][:exceeds_threshold]
- return "rate_climbing" if kpis[:no_result_rate][:point_change].to_f.positive?
- return "shrinking" if kpis[:total_searches][:percent_change].to_f.negative?
-
- "healthy"
- end
-
def trending
rows =
non_staff_search_logs_in(window_start: start_date, window_end: end_date)
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 481e34af124..78e7e999110 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -7456,24 +7456,81 @@ en:
other: "%{count} members got demoted to this trust level"
stable_aria: "no movement"
headline:
- healthy_growth:
- title: "Members are forming a habit of coming back."
- summary: "Stickiness, daily engagement, and new sign-ups are all up this period."
- declining:
- title: "Members are coming back less often."
- summary: "Stickiness, daily engagement, and new sign-ups are all down this period."
- engaged_but_shrinking:
- title: "Members are engaged, but the community is shrinking."
- summary: "Stickiness is holding up, but daily engagement or new sign-ups have slipped."
- growing_but_distracted:
- title: "New members are signing up, but they're not sticking around."
- summary: "Sign-ups are up, but stickiness has dropped this period."
- mixed:
- title: "Engagement trends are mixed this period."
- summary: "Some metrics are up while others are down — open the tiles below for detail."
- no_signal:
- title: "Not enough activity yet to summarise engagement."
- summary: "Pick a longer date range or come back once your community has more activity."
+ titles:
+ engagement_up: "Engagement is up in the selected period"
+ stickiness_and_daily_engagement_increased: "Stickiness and daily engagement have increased in the selected period"
+ stickiness_and_new_signups_increased: "Stickiness and new signups have increased in the selected period"
+ stickiness_increased: "Stickiness has increased in the selected period"
+ daily_engagement_and_new_signups_increased: "Daily engagement and new signups have increased in the selected period"
+ daily_engagement_increased: "Daily engagement has increased in the selected period"
+ new_signups_increased: "New signups have increased in the selected period"
+ engagement_declined: "Engagement has declined in the selected period"
+ some_engagement_declines: "Some declines in engagement in the selected period"
+ engagement_steady: "Engagement is steady in the selected period"
+ insufficient_activity: "Not enough activity yet to summarise engagement."
+ summaries:
+ all_metrics_improved: "Stickiness, daily engagement, and new signups have all improved, showing that more members are joining and participating in your community."
+ stickiness_and_daily_engagement_up_new_signups_down: "Stickiness and daily engagement are up, but new signups are down."
+ stickiness_and_daily_engagement_up_new_signups_flat: "Stickiness and daily engagement are up, but new signups are flat."
+ stickiness_and_daily_engagement_up: "Stickiness and daily engagement are up."
+ stickiness_and_new_signups_up_daily_engagement_down: "Stickiness and new signups are up, but daily engagement is down."
+ stickiness_up_daily_engagement_and_new_signups_down: "Stickiness is up, but daily engagement and new signups are down."
+ stickiness_up_daily_engagement_down: "Stickiness is up, but daily engagement is down."
+ stickiness_and_new_signups_up_daily_engagement_flat: "Stickiness and new signups are up, but daily engagement is flat."
+ stickiness_up_new_signups_down: "Stickiness is up, but new signups are down."
+ stickiness_up_daily_engagement_and_new_signups_flat: "Stickiness is up, but daily engagement and new signups are flat."
+ stickiness_up_daily_engagement_flat: "Stickiness is up, but daily engagement is flat."
+ stickiness_and_new_signups_up: "Stickiness and new signups are up."
+ stickiness_up_new_signups_flat: "Stickiness is up, but new signups are flat."
+ stickiness_up: "Stickiness is up."
+ daily_engagement_and_new_signups_up_stickiness_down: "Daily engagement and new signups are up, but stickiness is down."
+ daily_engagement_up_stickiness_and_new_signups_down: "Daily engagement is up, but stickiness and new signups are down."
+ daily_engagement_up_stickiness_down: "Daily engagement is up, but stickiness is down."
+ new_signups_up_stickiness_and_daily_engagement_down: "New signups are up, but stickiness and daily engagement are down."
+ all_metrics_down: "Stickiness, daily engagement, and new signups are all down."
+ stickiness_and_daily_engagement_down_new_signups_steady: "Stickiness and daily engagement are down, but new signups are holding steady."
+ stickiness_and_daily_engagement_down: "Stickiness and daily engagement are down."
+ new_signups_up_stickiness_down: "New signups are up, but stickiness is down."
+ stickiness_and_new_signups_down_daily_engagement_steady: "Stickiness and new signups are down, but daily engagement is holding steady."
+ stickiness_down_daily_engagement_and_new_signups_steady: "Stickiness is down, but daily engagement and new signups are holding steady."
+ stickiness_down_daily_engagement_steady: "Stickiness is down, but daily engagement is holding steady."
+ stickiness_and_new_signups_down: "Stickiness and new signups are down."
+ stickiness_down_new_signups_steady: "Stickiness is down, but new signups are holding steady."
+ stickiness_down: "Stickiness is down."
+ daily_engagement_and_new_signups_up_stickiness_flat: "Daily engagement and new signups are up, but stickiness is flat."
+ daily_engagement_up_new_signups_down: "Daily engagement is up, but new signups are down."
+ daily_engagement_up_stickiness_and_new_signups_flat: "Daily engagement is up, but stickiness and new signups are flat."
+ daily_engagement_up_stickiness_flat: "Daily engagement is up, but stickiness is flat."
+ new_signups_up_daily_engagement_down: "New signups are up, but daily engagement is down."
+ daily_engagement_and_new_signups_down_stickiness_steady: "Daily engagement and new signups are down, but stickiness is holding steady."
+ daily_engagement_down_stickiness_and_new_signups_steady: "Daily engagement is down, but stickiness and new signups are holding steady."
+ daily_engagement_down_stickiness_steady: "Daily engagement is down, but stickiness is holding steady."
+ new_signups_up_stickiness_and_daily_engagement_flat: "New signups are up, but stickiness and daily engagement are flat."
+ new_signups_down_stickiness_and_daily_engagement_steady: "New signups are down, but stickiness and daily engagement are holding steady."
+ all_metrics_steady: "No meaningful change in stickiness, daily engagement, or new signups."
+ stickiness_and_daily_engagement_steady: "No meaningful change in stickiness and daily engagement."
+ new_signups_up_stickiness_flat: "New signups are up, but stickiness is flat."
+ new_signups_down_stickiness_steady: "New signups are down, but stickiness is holding steady."
+ stickiness_and_new_signups_steady: "No meaningful change in stickiness and new signups."
+ stickiness_steady: "No meaningful change in stickiness."
+ daily_engagement_and_new_signups_up: "Daily engagement and new signups are up."
+ daily_engagement_up_new_signups_flat: "Daily engagement is up, but new signups are flat."
+ daily_engagement_up: "Daily engagement is up."
+ daily_engagement_and_new_signups_down: "Daily engagement and new signups are down."
+ daily_engagement_down_new_signups_steady: "Daily engagement is down, but new signups are holding steady."
+ daily_engagement_down: "Daily engagement is down."
+ new_signups_up_daily_engagement_flat: "New signups are up, but daily engagement is flat."
+ new_signups_down_daily_engagement_steady: "New signups are down, but daily engagement is holding steady."
+ daily_engagement_and_new_signups_steady: "No meaningful change in daily engagement and new signups."
+ daily_engagement_steady: "No meaningful change in daily engagement."
+ new_signups_up: "New signups are up."
+ new_signups_down: "New signups are down."
+ new_signups_steady: "No meaningful change in new signups."
+ insufficient_activity: "Pick a longer date range or come back once your community has more activity."
+ cta:
+ dau_mau: "Take a look at the activity by category to see which areas of your community may need your attention."
+ daily_engaged_users: "Investigate the decline to see which members have disengaged."
+ new_signups: "Look at your site traffic data to understand how traffic patterns might be influencing your signups this period."
metrics:
new_signups: "New sign-ups"
dau_mau: "DAU / MAU stickiness"
@@ -7483,26 +7540,35 @@ en:
fetch_error: "Couldn't load search data. Try refreshing the page."
logging_disabled: 'Search logging is disabled, so no search data is being collected. Enable <a href="%{basePath}/admin/site_settings/category/all_results?filter=log%20search%20queries">log search queries</a> to start collecting it.'
logging_disabled_moderator: "Search logging is disabled, so no search data is being collected. Ask an admin to enable log search queries to start collecting it."
- count_headline:
- last_7_days:
- one: "Members ran %{formatted_count} on-site search in the last 7 days"
- other: "Members ran %{formatted_count} on-site searches in the last 7 days"
- last_30_days:
- one: "Members ran %{formatted_count} on-site search in the last 30 days"
- other: "Members ran %{formatted_count} on-site searches in the last 30 days"
- last_3_months:
- one: "Members ran %{formatted_count} on-site search in the last 3 months"
- other: "Members ran %{formatted_count} on-site searches in the last 3 months"
- selected_period:
- one: "Members ran %{formatted_count} on-site search in the selected period"
- other: "Members ran %{formatted_count} on-site searches in the selected period"
headline:
- no_signal_title: "Not enough search activity to summarise yet."
- no_signal: "Pick a longer date range or come back once members have searched more."
- content_gaps: "More than 10% of member searches ended without a click this period. Review the content gaps below to see what's missing."
- rate_climbing: "The no-result rate is climbing compared with the previous period. Keep an eye on the content gaps below."
- shrinking: "Search volume is down compared with the previous period, while most searches still lead to content."
- healthy: "Members keep finding what they search for, and search volume is steady or growing."
+ titles:
+ insufficient_activity: "Not enough search activity to summarise yet."
+ searches_increased_no_result_rate_declined: "Searches have increased and the no-result rate has declined in the selected period"
+ searches_increased: "The total number of searches has increased in the selected period"
+ no_result_rate_decreased: "The no-result rate has decreased in the selected period"
+ searches_decreased_no_result_rate_increased: "Searches have decreased and the no-result rate has gone up in the selected period"
+ searches_decreased: "The total number of searches has decreased in the selected period"
+ no_result_rate_increased: "The no-result rate has increased in the selected period"
+ search_steady: "Search is steady in the selected period"
+ summaries:
+ insufficient_activity: "Pick a longer date range or come back once members have searched more."
+ searches_up_results_improved: "Members are conducting more searches in your community and are finding what they're looking for more often."
+ searches_up_no_result_rate_up: "Members are conducting more searches in your community, but the no-result rate has increased."
+ searches_up_no_result_rate_flat: "Members are conducting more searches in your community, but the no-result rate is flat."
+ results_improved_searches_down: "Members are finding what they're looking for, and total search volume has decreased."
+ results_improved_searches_steady: "Members are finding what they're looking for, and total search volume is flat."
+ searches_down_results_worsened: "Members are conducting fewer searches in your community and are not finding what they need as often."
+ searches_down_no_result_rate_flat: "Members are conducting fewer searches in your community, but the no-result rate is flat."
+ results_worsened_searches_steady: "Members are not finding what they need as often, and total search volume is holding steady."
+ searches_and_no_result_rate_steady: "No meaningful change in total searches or the no-result rate."
+ searches_up: "Members are conducting more searches in your community."
+ searches_down: "Members are conducting fewer searches in your community."
+ searches_steady: "No meaningful change in total searches."
+ results_worsened: "Members are not finding what they need as often."
+ results_improved: "Members are finding what they're looking for more often."
+ no_result_rate_steady: "No meaningful change in the no-result rate."
+ cta:
+ content_gaps: "Review the content gaps to see what's missing."
kpi:
total_searches:
label: "Total searches"
diff --git a/frontend/discourse/admin/components/dashboard/engagement.gjs b/frontend/discourse/admin/components/dashboard/engagement.gjs
index c4b9da24a2b..746b0201219 100644
--- a/frontend/discourse/admin/components/dashboard/engagement.gjs
+++ b/frontend/discourse/admin/components/dashboard/engagement.gjs
@@ -17,12 +17,8 @@ export default <template>
{{i18n "admin.dashboard.sections.engagement.fetch_error"}}
</div>
{{else}}
- {{#if @engagement.headline}}
- <EngagementHeadline
- @headline={{@engagement.headline}}
- @kpis={{@engagement.kpis}}
- @period={{@period}}
- />
+ {{#if @engagement}}
+ <EngagementHeadline @kpis={{@engagement.kpis}} />
{{/if}}
<div class="db-section__row-group">
diff --git a/frontend/discourse/admin/components/dashboard/engagement/headline.gjs b/frontend/discourse/admin/components/dashboard/engagement/headline.gjs
index 20d7232cced..67063290ecb 100644
--- a/frontend/discourse/admin/components/dashboard/engagement/headline.gjs
+++ b/frontend/discourse/admin/components/dashboard/engagement/headline.gjs
@@ -4,13 +4,45 @@ import { LinkTo } from "@ember/routing";
import {
formatDeltaPercent,
formatKpiValue,
+ roundDeltaPercent,
} from "discourse/admin/lib/dashboard-format";
+import { engagementHeadlineKeys } from "discourse/admin/lib/engagement-headline";
import DTooltip from "discourse/float-kit/components/d-tooltip";
import { eq } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
-const PRESET_PERIODS = ["last_7_days", "last_30_days", "last_3_months"];
const PERCENTAGE_KPIS = ["dau_mau"];
+const METRIC_ORDER = ["dau_mau", "daily_engaged_users", "new_signups"];
+
+function direction(metric) {
+ if (metric?.value == null) {
+ return "unavailable";
+ }
+
+ if (metric.previous_value == null || metric.previous_value === 0) {
+ return metric.value > 0 ? "improved" : "flat";
+ }
+
+ const change =
+ metric.percent_change ??
+ ((metric.value - metric.previous_value) / metric.previous_value) * 100;
+ const roundedChange = roundDeltaPercent(change);
+
+ if (roundedChange > 0) {
+ return "improved";
+ } else if (roundedChange < 0) {
+ return "declined";
+ }
+
+ return "flat";
+}
+
+function percentChange(metric) {
+ return (
+ metric.percent_change ??
+ ((metric.value - metric.previous_value) / metric.previous_value) * 100
+ );
+}
class MetricItem extends Component {
get isPercentage() {
@@ -75,7 +107,6 @@ class MetricItem extends Component {
{{else}}
<div class={{concat "db-delta " this.deltaClass}}>
{{this.deltaText}}
- <span class="db-delta__label">{{@comparisonLabel}}</span>
</div>
{{/if}}
{{/if}}
@@ -84,26 +115,49 @@ class MetricItem extends Component {
}
export default class EngagementHeadline extends Component {
- get titleKey() {
- return `${this.args.headline.key}.title`;
- }
-
- get summaryKey() {
- return `${this.args.headline.key}.summary`;
- }
+ get headline() {
+ const prefix = "admin.dashboard.sections.engagement.headline";
+ const metricsByType = new Map(
+ this.args.kpis.map((metric) => [metric.type, metric])
+ );
+ const metrics = METRIC_ORDER.map((type) => {
+ const metric = metricsByType.get(type) ?? { type };
+ return { ...metric, direction: direction(metric) };
+ });
+ const declined = metrics.filter(
+ (metric) => metric.direction === "declined"
+ );
+ const ctaOwner = declined.reduce((most, metric) => {
+ if (!most) {
+ return metric;
+ }
+ return roundDeltaPercent(percentChange(metric)) <
+ roundDeltaPercent(percentChange(most))
+ ? metric
+ : most;
+ }, null)?.type;
+ const directionsByType = Object.fromEntries(
+ metrics.map((metric) => [metric.type, metric.direction])
+ );
+ const headlineKeys = engagementHeadlineKeys({
+ stickiness: directionsByType.dau_mau,
+ dailyEngagement: directionsByType.daily_engaged_users,
+ newSignups: directionsByType.new_signups,
+ });
+ const summary = i18n(`${prefix}.summaries.${headlineKeys.summary}`);
+ const cta = ctaOwner ? i18n(`${prefix}.cta.${ctaOwner}`) : null;
- get comparisonLabel() {
- const key = PRESET_PERIODS.includes(this.args.period)
- ? this.args.period
- : "previous_period";
- return i18n(`admin.dashboard.highlights.comparison.${key}`);
+ return {
+ title: i18n(`${prefix}.titles.${headlineKeys.title}`),
+ summary: cta ? `${summary} ${cta}` : summary,
+ };
}
<template>
<div class="db-section__subheader">
<div class="db-section__subintro">
- <h3>{{i18n this.titleKey}}</h3>
- <p>{{i18n this.summaryKey}}</p>
+ <h3>{{this.headline.title}}</h3>
+ <p>{{this.headline.summary}}</p>
</div>
<div class="db-section__metrics">
{{#each @kpis as |metric|}}
diff --git a/frontend/discourse/admin/components/dashboard/search.gjs b/frontend/discourse/admin/components/dashboard/search.gjs
index 48b75a78be8..a205057fcf7 100644
--- a/frontend/discourse/admin/components/dashboard/search.gjs
+++ b/frontend/discourse/admin/components/dashboard/search.gjs
@@ -5,17 +5,12 @@ import { service } from "@ember/service";
import { trustHTML } from "@ember/template";
import DashboardSection from "discourse/admin/components/dashboard/section";
import { formatDeltaPercent } from "discourse/admin/lib/dashboard-format";
+import { searchHeadlineKeys } from "discourse/admin/lib/search-headline";
import DTooltip from "discourse/float-kit/components/d-tooltip";
import dBasePath from "discourse/ui-kit/helpers/d-base-path";
import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";
import I18n, { i18n } from "discourse-i18n";
-const COUNT_HEADLINE_KEYS = {
- last_7_days: "admin.dashboard.sections.search.count_headline.last_7_days",
- last_30_days: "admin.dashboard.sections.search.count_headline.last_30_days",
- last_3_months: "admin.dashboard.sections.search.count_headline.last_3_months",
-};
-
function formatCount(value) {
return I18n.toNumber(value, { precision: 0 });
}
@@ -37,27 +32,62 @@ export default class DashboardSearch extends Component {
return this.args.search?.logging_enabled === false;
}
- get isNoSignal() {
- return this.args.search.headline_state === "no_signal";
- }
+ get headline() {
+ const prefix = "admin.dashboard.sections.search.headline";
+ const totalSearches = this.args.search.kpis.total_searches;
+ const noResultRate = this.args.search.kpis.no_result_rate;
- get headlineTitle() {
- if (this.isNoSignal) {
- return i18n("admin.dashboard.sections.search.headline.no_signal_title");
+ if (
+ totalSearches.value === 0 &&
+ totalSearches.previous_value === 0 &&
+ noResultRate.value == null
+ ) {
+ const headlineKeys = searchHeadlineKeys({ noData: true });
+ return {
+ title: i18n(`${prefix}.titles.${headlineKeys.title}`),
+ summary: i18n(`${prefix}.summaries.${headlineKeys.summary}`),
+ };
}
- const count = this.args.search.kpis.total_searches.value;
- const key =
- COUNT_HEADLINE_KEYS[this.args.period] ??
- "admin.dashboard.sections.search.count_headline.selected_period";
+ const searchesDirection = this.#direction(
+ totalSearches,
+ totalSearches.percent_change
+ );
+ const noResultDirection = this.#direction(
+ noResultRate,
+ noResultRate.point_change
+ );
+ const headlineKeys = searchHeadlineKeys({
+ searches: searchesDirection,
+ noResultRate: noResultDirection,
+ });
+ const summary = i18n(`${prefix}.summaries.${headlineKeys.summary}`);
+ const cta = headlineKeys.cta
+ ? i18n(`${prefix}.cta.${headlineKeys.cta}`)
+ : null;
- return i18n(key, { count, formatted_count: formatCount(count) });
+ return {
+ title: i18n(`${prefix}.titles.${headlineKeys.title}`),
+ summary: cta ? `${summary} ${cta}` : summary,
+ };
}
- get headlineSummary() {
- return i18n(
- `admin.dashboard.sections.search.headline.${this.args.search.headline_state}`
- );
+ #direction(kpi, change) {
+ if (kpi.value == null) {
+ return "unavailable";
+ }
+
+ if (kpi.previous_value == null || kpi.previous_value === 0) {
+ return kpi.value > 0 ? "up" : "flat";
+ }
+
+ if (change > 0) {
+ return "up";
+ } else if (change < 0) {
+ return "down";
+ }
+
+ return "flat";
}
get totalSearchesValue() {
@@ -136,8 +166,8 @@ export default class DashboardSearch extends Component {
{{else if @search}}
<div class="db-section__subheader">
<div class="db-section__subintro">
- <h3>{{this.headlineTitle}}</h3>
- <p>{{this.headlineSummary}}</p>
+ <h3>{{this.headline.title}}</h3>
+ <p>{{this.headline.summary}}</p>
</div>
<div class="db-section__metrics">
diff --git a/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs b/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
index c43147fd7d7..a81a216a68a 100644
--- a/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
+++ b/frontend/discourse/admin/components/redesigned-admin-dashboard.gjs
@@ -127,7 +127,6 @@ export default class RedesignedAdminDashboard extends Component {
class={{concat "--" section.id}}
data-section-id={{section.id}}
@engagement={{section.data}}
- @period={{@loadedSections.period}}
@loading={{@loadingSections}}
@fetchError={{section.error}}
@startDate={{@loadedSections.startDate}}
diff --git a/frontend/discourse/admin/lib/dashboard-format.js b/frontend/discourse/admin/lib/dashboard-format.js
index 65de9cff800..551fdd0bd52 100644
--- a/frontend/discourse/admin/lib/dashboard-format.js
+++ b/frontend/discourse/admin/lib/dashboard-format.js
@@ -10,15 +10,25 @@ export function formatKpiValue(value, { percentage = false } = {}) {
return I18n.toNumber(value, { precision: 0 });
}
-export function formatDeltaPercent(value) {
+export function roundDeltaPercent(value) {
const abs = Math.abs(value);
if (abs > 0 && abs < 1) {
+ const roundedAbs = Math.round(abs * 10) / 10;
+ return value < 0 ? -roundedAbs : roundedAbs;
+ }
+
+ return Math.round(value);
+}
+
+export function formatDeltaPercent(value) {
+ const rounded = roundDeltaPercent(value);
+
+ if (Math.abs(value) > 0 && Math.abs(value) < 1) {
const sign = value > 0 ? "+" : "-";
- return `${sign}${I18n.toNumber(abs, { precision: 1 })}%`;
+ return `${sign}${I18n.toNumber(Math.abs(rounded), { precision: 1 })}%`;
}
- const rounded = Math.round(value);
const sign = rounded > 0 ? "+" : "";
return `${sign}${I18n.toNumber(rounded, { precision: 0 })}%`;
}
diff --git a/frontend/discourse/admin/lib/engagement-headline.js b/frontend/discourse/admin/lib/engagement-headline.js
new file mode 100644
index 00000000000..ec114c713a8
--- /dev/null
+++ b/frontend/discourse/admin/lib/engagement-headline.js
@@ -0,0 +1,268 @@
+const HEADLINE_BY_SCENARIO = {
+ "stickiness=improved|daily_engagement=improved|new_signups=improved": {
+ title: "engagement_up",
+ summary: "all_metrics_improved",
+ },
+ "stickiness=improved|daily_engagement=improved|new_signups=declined": {
+ title: "stickiness_and_daily_engagement_increased",
+ summary: "stickiness_and_daily_engagement_up_new_signups_down",
+ },
+ "stickiness=improved|daily_engagement=improved|new_signups=flat": {
+ title: "stickiness_and_daily_engagement_increased",
+ summary: "stickiness_and_daily_engagement_up_new_signups_flat",
+ },
+ "stickiness=improved|daily_engagement=improved|new_signups=unavailable": {
+ title: "stickiness_and_daily_engagement_increased",
+ summary: "stickiness_and_daily_engagement_up",
+ },
+ "stickiness=improved|daily_engagement=declined|new_signups=improved": {
+ title: "stickiness_and_new_signups_increased",
+ summary: "stickiness_and_new_signups_up_daily_engagement_down",
+ },
+ "stickiness=improved|daily_engagement=declined|new_signups=declined": {
+ title: "stickiness_increased",
+ summary: "stickiness_up_daily_engagement_and_new_signups_down",
+ },
+ "stickiness=improved|daily_engagement=declined|new_signups=flat": {
+ title: "stickiness_increased",
+ summary: "stickiness_up_daily_engagement_down",
+ },
+ "stickiness=improved|daily_engagement=declined|new_signups=unavailable": {
+ title: "stickiness_increased",
+ summary: "stickiness_up_daily_engagement_down",
+ },
+ "stickiness=improved|daily_engagement=flat|new_signups=improved": {
+ title: "stickiness_and_new_signups_increased",
+ summary: "stickiness_and_new_signups_up_daily_engagement_flat",
+ },
+ "stickiness=improved|daily_engagement=flat|new_signups=declined": {
+ title: "stickiness_increased",
+ summary: "stickiness_up_new_signups_down",
+ },
+ "stickiness=improved|daily_engagement=flat|new_signups=flat": {
+ title: "stickiness_increased",
+ summary: "stickiness_up_daily_engagement_and_new_signups_flat",
+ },
+ "stickiness=improved|daily_engagement=flat|new_signups=unavailable": {
+ title: "stickiness_increased",
+ summary: "stickiness_up_daily_engagement_flat",
+ },
+ "stickiness=improved|daily_engagement=unavailable|new_signups=improved": {
+ title: "stickiness_and_new_signups_increased",
+ summary: "stickiness_and_new_signups_up",
+ },
+ "stickiness=improved|daily_engagement=unavailable|new_signups=declined": {
+ title: "stickiness_increased",
+ summary: "stickiness_up_new_signups_down",
+ },
+ "stickiness=improved|daily_engagement=unavailable|new_signups=flat": {
+ title: "stickiness_increased",
+ summary: "stickiness_up_new_signups_flat",
+ },
+ "stickiness=improved|daily_engagement=unavailable|new_signups=unavailable": {
+ title: "stickiness_increased",
+ summary: "stickiness_up",
+ },
+ "stickiness=declined|daily_engagement=improved|new_signups=improved": {
+ title: "daily_engagement_and_new_signups_increased",
+ summary: "daily_engagement_and_new_signups_up_stickiness_down",
+ },
+ "stickiness=declined|daily_engagement=improved|new_signups=declined": {
+ title: "daily_engagement_increased",
+ summary: "daily_engagement_up_stickiness_and_new_signups_down",
+ },
+ "stickiness=declined|daily_engagement=improved|new_signups=flat": {
+ title: "daily_engagement_increased",
+ summary: "daily_engagement_up_stickiness_down",
+ },
+ "stickiness=declined|daily_engagement=improved|new_signups=unavailable": {
+ title: "daily_engagement_increased",
+ summary: "daily_engagement_up_stickiness_down",
+ },
+ "stickiness=declined|daily_engagement=declined|new_signups=improved": {
+ title: "new_signups_increased",
+ summary: "new_signups_up_stickiness_and_daily_engagement_down",
+ },
+ "stickiness=declined|daily_engagement=declined|new_signups=declined": {
+ title: "engagement_declined",
+ summary: "all_metrics_down",
+ },
+ "stickiness=declined|daily_engagement=declined|new_signups=flat": {
+ title: "some_engagement_declines",
+ summary: "stickiness_and_daily_engagement_down_new_signups_steady",
+ },
+ "stickiness=declined|daily_engagement=declined|new_signups=unavailable": {
+ title: "engagement_declined",
+ summary: "stickiness_and_daily_engagement_down",
+ },
+ "stickiness=declined|daily_engagement=flat|new_signups=improved": {
+ title: "new_signups_increased",
+ summary: "new_signups_up_stickiness_down",
+ },
+ "stickiness=declined|daily_engagement=flat|new_signups=declined": {
+ title: "some_engagement_declines",
+ summary: "stickiness_and_new_signups_down_daily_engagement_steady",
+ },
+ "stickiness=declined|daily_engagement=flat|new_signups=flat": {
+ title: "some_engagement_declines",
+ summary: "stickiness_down_daily_engagement_and_new_signups_steady",
+ },
+ "stickiness=declined|daily_engagement=flat|new_signups=unavailable": {
+ title: "some_engagement_declines",
+ summary: "stickiness_down_daily_engagement_steady",
+ },
+ "stickiness=declined|daily_engagement=unavailable|new_signups=improved": {
+ title: "new_signups_increased",
+ summary: "new_signups_up_stickiness_down",
+ },
+ "stickiness=declined|daily_engagement=unavailable|new_signups=declined": {
+ title: "engagement_declined",
+ summary: "stickiness_and_new_signups_down",
+ },
+ "stickiness=declined|daily_engagement=unavailable|new_signups=flat": {
+ title: "some_engagement_declines",
+ summary: "stickiness_down_new_signups_steady",
+ },
+ "stickiness=declined|daily_engagement=unavailable|new_signups=unavailable": {
+ title: "engagement_declined",
+ summary: "stickiness_down",
+ },
+ "stickiness=flat|daily_engagement=improved|new_signups=improved": {
+ title: "daily_engagement_and_new_signups_increased",
+ summary: "daily_engagement_and_new_signups_up_stickiness_flat",
+ },
+ "stickiness=flat|daily_engagement=improved|new_signups=declined": {
+ title: "daily_engagement_increased",
+ summary: "daily_engagement_up_new_signups_down",
+ },
+ "stickiness=flat|daily_engagement=improved|new_signups=flat": {
+ title: "daily_engagement_increased",
+ summary: "daily_engagement_up_stickiness_and_new_signups_flat",
+ },
+ "stickiness=flat|daily_engagement=improved|new_signups=unavailable": {
+ title: "daily_engagement_increased",
+ summary: "daily_engagement_up_stickiness_flat",
+ },
+ "stickiness=flat|daily_engagement=declined|new_signups=improved": {
+ title: "new_signups_increased",
+ summary: "new_signups_up_daily_engagement_down",
+ },
+ "stickiness=flat|daily_engagement=declined|new_signups=declined": {
+ title: "some_engagement_declines",
+ summary: "daily_engagement_and_new_signups_down_stickiness_steady",
+ },
+ "stickiness=flat|daily_engagement=declined|new_signups=flat": {
+ title: "some_engagement_declines",
+ summary: "daily_engagement_down_stickiness_and_new_signups_steady",
+ },
+ "stickiness=flat|daily_engagement=declined|new_signups=unavailable": {
+ title: "some_engagement_declines",
+ summary: "daily_engagement_down_stickiness_steady",
+ },
+ "stickiness=flat|daily_engagement=flat|new_signups=improved": {
+ title: "new_signups_increased",
+ summary: "new_signups_up_stickiness_and_daily_engagement_flat",
+ },
+ "stickiness=flat|daily_engagement=flat|new_signups=declined": {
+ title: "some_engagement_declines",
+ summary: "new_signups_down_stickiness_and_daily_engagement_steady",
+ },
+ "stickiness=flat|daily_engagement=flat|new_signups=flat": {
+ title: "engagement_steady",
+ summary: "all_metrics_steady",
+ },
+ "stickiness=flat|daily_engagement=flat|new_signups=unavailable": {
+ title: "engagement_steady",
+ summary: "stickiness_and_daily_engagement_steady",
+ },
+ "stickiness=flat|daily_engagement=unavailable|new_signups=improved": {
+ title: "new_signups_increased",
+ summary: "new_signups_up_stickiness_flat",
+ },
+ "stickiness=flat|daily_engagement=unavailable|new_signups=declined": {
+ title: "some_engagement_declines",
+ summary: "new_signups_down_stickiness_steady",
+ },
+ "stickiness=flat|daily_engagement=unavailable|new_signups=flat": {
+ title: "engagement_steady",
+ summary: "stickiness_and_new_signups_steady",
+ },
+ "stickiness=flat|daily_engagement=unavailable|new_signups=unavailable": {
+ title: "engagement_steady",
+ summary: "stickiness_steady",
+ },
+ "stickiness=unavailable|daily_engagement=improved|new_signups=improved": {
+ title: "daily_engagement_and_new_signups_increased",
+ summary: "daily_engagement_and_new_signups_up",
+ },
+ "stickiness=unavailable|daily_engagement=improved|new_signups=declined": {
+ title: "daily_engagement_increased",
+ summary: "daily_engagement_up_new_signups_down",
+ },
+ "stickiness=unavailable|daily_engagement=improved|new_signups=flat": {
+ title: "daily_engagement_increased",
+ summary: "daily_engagement_up_new_signups_flat",
+ },
+ "stickiness=unavailable|daily_engagement=improved|new_signups=unavailable": {
+ title: "daily_engagement_increased",
+ summary: "daily_engagement_up",
+ },
+ "stickiness=unavailable|daily_engagement=declined|new_signups=improved": {
+ title: "new_signups_increased",
+ summary: "new_signups_up_daily_engagement_down",
+ },
+ "stickiness=unavailable|daily_engagement=declined|new_signups=declined": {
+ title: "engagement_declined",
+ summary: "daily_engagement_and_new_signups_down",
+ },
+ "stickiness=unavailable|daily_engagement=declined|new_signups=flat": {
+ title: "some_engagement_declines",
+ summary: "daily_engagement_down_new_signups_steady",
+ },
+ "stickiness=unavailable|daily_engagement=declined|new_signups=unavailable": {
+ title: "engagement_declined",
+ summary: "daily_engagement_down",
+ },
+ "stickiness=unavailable|daily_engagement=flat|new_signups=improved": {
+ title: "new_signups_increased",
+ summary: "new_signups_up_daily_engagement_flat",
+ },
+ "stickiness=unavailable|daily_engagement=flat|new_signups=declined": {
+ title: "some_engagement_declines",
+ summary: "new_signups_down_daily_engagement_steady",
+ },
+ "stickiness=unavailable|daily_engagement=flat|new_signups=flat": {
+ title: "engagement_steady",
+ summary: "daily_engagement_and_new_signups_steady",
+ },
+ "stickiness=unavailable|daily_engagement=flat|new_signups=unavailable": {
+ title: "engagement_steady",
+ summary: "daily_engagement_steady",
+ },
+ "stickiness=unavailable|daily_engagement=unavailable|new_signups=improved": {
+ title: "new_signups_increased",
+ summary: "new_signups_up",
+ },
+ "stickiness=unavailable|daily_engagement=unavailable|new_signups=declined": {
+ title: "engagement_declined",
+ summary: "new_signups_down",
+ },
+ "stickiness=unavailable|daily_engagement=unavailable|new_signups=flat": {
+ title: "engagement_steady",
+ summary: "new_signups_steady",
+ },
+ "stickiness=unavailable|daily_engagement=unavailable|new_signups=unavailable":
+ {
+ title: "insufficient_activity",
+ summary: "insufficient_activity",
+ },
+};
+
+function scenarioKey({ stickiness, dailyEngagement, newSignups }) {
+ return `stickiness=${stickiness}|daily_engagement=${dailyEngagement}|new_signups=${newSignups}`;
+}
+
+export function engagementHeadlineKeys(directions) {
+ const scenario = scenarioKey(directions);
+ return HEADLINE_BY_SCENARIO[scenario];
+}
diff --git a/frontend/discourse/admin/lib/search-headline.js b/frontend/discourse/admin/lib/search-headline.js
new file mode 100644
index 00000000000..1e9911a61b1
--- /dev/null
+++ b/frontend/discourse/admin/lib/search-headline.js
@@ -0,0 +1,84 @@
+const HEADLINE_BY_SCENARIO = {
+ no_data: {
+ title: "insufficient_activity",
+ summary: "insufficient_activity",
+ },
+ "searches=up|no_result_rate=down": {
+ title: "searches_increased_no_result_rate_declined",
+ summary: "searches_up_results_improved",
+ },
+ "searches=up|no_result_rate=up": {
+ title: "searches_increased",
+ summary: "searches_up_no_result_rate_up",
+ cta: "content_gaps",
+ },
+ "searches=up|no_result_rate=flat": {
+ title: "searches_increased",
+ summary: "searches_up_no_result_rate_flat",
+ cta: "content_gaps",
+ },
+ "searches=down|no_result_rate=down": {
+ title: "no_result_rate_decreased",
+ summary: "results_improved_searches_down",
+ },
+ "searches=flat|no_result_rate=down": {
+ title: "no_result_rate_decreased",
+ summary: "results_improved_searches_steady",
+ },
+ "searches=down|no_result_rate=up": {
+ title: "searches_decreased_no_result_rate_increased",
+ summary: "searches_down_results_worsened",
+ cta: "content_gaps",
+ },
+ "searches=down|no_result_rate=flat": {
+ title: "searches_decreased",
+ summary: "searches_down_no_result_rate_flat",
+ },
+ "searches=flat|no_result_rate=up": {
+ title: "no_result_rate_increased",
+ summary: "results_worsened_searches_steady",
+ cta: "content_gaps",
+ },
+ "searches=flat|no_result_rate=flat": {
+ title: "search_steady",
+ summary: "searches_and_no_result_rate_steady",
+ },
+ "searches=up|no_result_rate=unavailable": {
+ title: "searches_increased",
+ summary: "searches_up",
+ },
+ "searches=down|no_result_rate=unavailable": {
+ title: "searches_decreased",
+ summary: "searches_down",
+ },
+ "searches=flat|no_result_rate=unavailable": {
+ title: "search_steady",
+ summary: "searches_steady",
+ },
+ "searches=unavailable|no_result_rate=up": {
+ title: "no_result_rate_increased",
+ summary: "results_worsened",
+ cta: "content_gaps",
+ },
+ "searches=unavailable|no_result_rate=down": {
+ title: "no_result_rate_decreased",
+ summary: "results_improved",
+ },
+ "searches=unavailable|no_result_rate=flat": {
+ title: "search_steady",
+ summary: "no_result_rate_steady",
+ },
+};
+
+function scenarioKey({ searches, noResultRate, noData = false }) {
+ if (noData) {
+ return "no_data";
+ }
+
+ return `searches=${searches}|no_result_rate=${noResultRate}`;
+}
+
+export function searchHeadlineKeys(directions) {
+ const scenario = scenarioKey(directions);
+ return HEADLINE_BY_SCENARIO[scenario];
+}
diff --git a/frontend/discourse/tests/integration/components/dashboard/engagement-test.gjs b/frontend/discourse/tests/integration/components/dashboard/engagement-test.gjs
index 149526d793f..197ca3ea79b 100644
--- a/frontend/discourse/tests/integration/components/dashboard/engagement-test.gjs
+++ b/frontend/discourse/tests/integration/components/dashboard/engagement-test.gjs
@@ -11,9 +11,6 @@ module("Integration | Component | Dashboard | Engagement", function (hooks) {
const reportQuery = { start_date: "2026-04-01", end_date: "2026-04-30" };
const engagement = {
- headline: {
- key: "admin.dashboard.sections.engagement.headline.healthy_growth",
- },
kpis: [
{
type: "dau_mau",
@@ -39,22 +36,17 @@ module("Integration | Component | Dashboard | Engagement", function (hooks) {
],
};
- test("renders the headline title, summary and one metric per kpi", async function (assert) {
+ test("shows every KPI with its formatted value", async function (assert) {
await render(
<template>
<DashboardEngagement
@engagement={{engagement}}
- @period="last_30_days"
@startDate={{start}}
@endDate={{end}}
/>
</template>
);
- assert
- .dom(".db-section__subintro h3")
- .hasText("Members are forming a habit of coming back.");
- assert.dom(".db-section__subintro p").exists();
assert.dom(".db-section__metric").exists({ count: 3 });
assert
.dom(
@@ -102,4 +94,188 @@ module("Integration | Component | Dashboard | Engagement", function (hooks) {
assert.dom(".db-section__subintro").doesNotExist();
});
+
+ test("shows new activity as an increase when the prior period has no activity", async function (assert) {
+ const scenarioEngagement = {
+ kpis: [
+ {
+ type: "new_signups",
+ value: 10,
+ previous_value: null,
+ percent_change: null,
+ },
+ ],
+ };
+
+ await render(
+ <template>
+ <DashboardEngagement @engagement={{scenarioEngagement}} />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro")
+ .hasText(
+ "New signups have increased in the selected period New signups are up."
+ );
+ });
+
+ test("shows the no-data message when no metric is measurable", async function (assert) {
+ const scenarioEngagement = {
+ kpis: [],
+ };
+
+ await render(
+ <template>
+ <DashboardEngagement @engagement={{scenarioEngagement}} />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro")
+ .hasText(
+ "Not enough activity yet to summarise engagement. Pick a longer date range or come back once your community has more activity."
+ );
+ });
+
+ test("shows a decline when a negative half-step rounds to -0.1%", async function (assert) {
+ const scenarioEngagement = {
+ kpis: [
+ {
+ type: "dau_mau",
+ value: 1999,
+ previous_value: 2000,
+ percent_change: -0.05,
+ },
+ ],
+ };
+
+ await render(
+ <template>
+ <DashboardEngagement @engagement={{scenarioEngagement}} />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro")
+ .hasText(
+ "Engagement has declined in the selected period Stickiness is down. Take a look at the activity by category to see which areas of your community may need your attention."
+ );
+ });
+
+ test("recommends investigating disengaged members when daily engagement has the largest displayed decline", async function (assert) {
+ const scenarioEngagement = {
+ kpis: [
+ {
+ type: "dau_mau",
+ value: 99.4,
+ previous_value: 100,
+ percent_change: -0.6,
+ },
+ {
+ type: "daily_engaged_users",
+ value: 98.6,
+ previous_value: 100,
+ percent_change: -1.4,
+ },
+ {
+ type: "new_signups",
+ value: 100,
+ previous_value: 100,
+ percent_change: 0,
+ },
+ ],
+ };
+
+ await render(
+ <template>
+ <DashboardEngagement @engagement={{scenarioEngagement}} />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro h3")
+ .hasText("Some declines in engagement in the selected period");
+ assert
+ .dom(".db-section__subintro p")
+ .hasText(
+ "Stickiness and daily engagement are down, but new signups are holding steady. Investigate the decline to see which members have disengaged.",
+ "recommends investigating disengaged members for the largest displayed decline"
+ );
+ });
+
+ test("recommends reviewing activity by category when stickiness and daily engagement have equal displayed declines", async function (assert) {
+ const scenarioEngagement = {
+ kpis: [
+ {
+ type: "dau_mau",
+ value: 89.6,
+ previous_value: 100,
+ percent_change: -10.4,
+ },
+ {
+ type: "daily_engaged_users",
+ value: 89.51,
+ previous_value: 100,
+ percent_change: -10.49,
+ },
+ {
+ type: "new_signups",
+ value: 100,
+ previous_value: 100,
+ percent_change: 0,
+ },
+ ],
+ };
+
+ await render(
+ <template>
+ <DashboardEngagement @engagement={{scenarioEngagement}} />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro p")
+ .hasText(
+ "Stickiness and daily engagement are down, but new signups are holding steady. Take a look at the activity by category to see which areas of your community may need your attention.",
+ "recommends reviewing activity by category for equal displayed declines"
+ );
+ });
+
+ test("summarizes measurable metrics when another metric is unavailable", async function (assert) {
+ const scenarioEngagement = {
+ kpis: [
+ {
+ type: "dau_mau",
+ value: null,
+ previous_value: null,
+ percent_change: null,
+ },
+ {
+ type: "daily_engaged_users",
+ value: 120,
+ previous_value: 100,
+ percent_change: 20,
+ },
+ {
+ type: "new_signups",
+ value: 40,
+ previous_value: 40,
+ percent_change: 0,
+ },
+ ],
+ };
+
+ await render(
+ <template>
+ <DashboardEngagement @engagement={{scenarioEngagement}} />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro")
+ .hasText(
+ "Daily engagement has increased in the selected period Daily engagement is up, but new signups are flat."
+ );
+ });
});
diff --git a/frontend/discourse/tests/integration/components/dashboard/search-test.gjs b/frontend/discourse/tests/integration/components/dashboard/search-test.gjs
new file mode 100644
index 00000000000..6d6b0d2c0cb
--- /dev/null
+++ b/frontend/discourse/tests/integration/components/dashboard/search-test.gjs
@@ -0,0 +1,84 @@
+import { find, render } from "@ember/test-helpers";
+import { module, test } from "qunit";
+import DashboardSearch from "discourse/admin/components/dashboard/search";
+import { setupRenderingTest } from "discourse/tests/helpers/component-test";
+
+const startDate = new Date("2026-04-01");
+const endDate = new Date("2026-04-30");
+
+module("Integration | Component | Dashboard | Search", function (hooks) {
+ setupRenderingTest(hooks);
+
+ test("shows improving search results when searches increase and the no-result rate declines", async function (assert) {
+ const search = {
+ logging_enabled: true,
+ kpis: {
+ total_searches: {
+ value: 120,
+ previous_value: 100,
+ percent_change: 20,
+ },
+ no_result_rate: {
+ value: 8,
+ previous_value: 10,
+ point_change: -2,
+ exceeds_threshold: false,
+ },
+ },
+ trending: [],
+ content_gaps: [],
+ trending_period: "monthly",
+ };
+
+ await render(
+ <template>
+ <DashboardSearch
+ @search={{search}}
+ @period="last_30_days"
+ @startDate={{startDate}}
+ @endDate={{endDate}}
+ />
+ </template>
+ );
+ assert.deepEqual(
+ [
+ find(".db-section__subintro h3").textContent.trim(),
+ find(".db-section__subintro p").textContent.trim(),
+ ],
+ [
+ "Searches have increased and the no-result rate has declined in the selected period",
+ "Members are conducting more searches in your community and are finding what they're looking for more often.",
+ ],
+ "renders the exact scenario headline and summary"
+ );
+ });
+
+ test("shows searches as increased when the prior period has no searches", async function (assert) {
+ const search = {
+ logging_enabled: true,
+ kpis: {
+ total_searches: { value: 10, previous_value: 0 },
+ no_result_rate: {
+ value: 20,
+ previous_value: null,
+ exceeds_threshold: true,
+ },
+ },
+ trending: [],
+ content_gaps: [],
+ trending_period: "monthly",
+ };
+
+ await render(
+ <template>
+ <DashboardSearch @search={{search}} @period="last_30_days" />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro")
+ .hasText(
+ "The total number of searches has increased in the selected period Members are conducting more searches in your community, but the no-result rate has increased. Review the content gaps to see what's missing."
+ );
+ });
+});
diff --git a/frontend/discourse/tests/unit/admin/lib/dashboard-format-test.js b/frontend/discourse/tests/unit/admin/lib/dashboard-format-test.js
index e7066a9bc2c..80ca10031d8 100644
--- a/frontend/discourse/tests/unit/admin/lib/dashboard-format-test.js
+++ b/frontend/discourse/tests/unit/admin/lib/dashboard-format-test.js
@@ -39,6 +39,10 @@ module("Unit | Admin | Lib | dashboard-format", function (hooks) {
assert.strictEqual(formatDeltaPercent(-0.4), "-0.4%");
});
+ test("rounds a negative sub-1% half step away from zero", function (assert) {
+ assert.strictEqual(formatDeltaPercent(-0.05), "-0.1%");
+ });
+
test("renders an exact-zero delta without a sign", function (assert) {
assert.strictEqual(formatDeltaPercent(0), "0%");
});
diff --git a/plugins/discourse-solved/admin/assets/javascripts/admin/components/dashboard/support.gjs b/plugins/discourse-solved/admin/assets/javascripts/admin/components/dashboard/support.gjs
index 863d6a8f7ba..1fe27b7c2e5 100644
--- a/plugins/discourse-solved/admin/assets/javascripts/admin/components/dashboard/support.gjs
+++ b/plugins/discourse-solved/admin/assets/javascripts/admin/components/dashboard/support.gjs
@@ -14,6 +14,7 @@ import Category from "discourse/models/category";
import MultipleCategoriesSelector from "discourse/select-kit/components/multiple-categories-selector";
import { eq } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
+import { supportHeadlineKeys } from "discourse/plugins/discourse-solved/admin/lib/support-headline";
import SupportResponseTime from "./support/response-time";
import SupportTopicOutcomes from "./support/topic-outcomes";
import SupportWhosAnswering from "./support/whos-answering";
@@ -70,60 +71,56 @@ export default class SupportSection extends Component {
}
get headline() {
- const headline = this.data?.headline;
- if (!headline) {
- return null;
- }
-
const prefix = "admin.dashboard.sections.support.headline";
- const titleKey = `${prefix}.${headline.key}.title`;
-
- if (headline.key === "no_data") {
- return { titleKey, summary: i18n(`${prefix}.no_data.summary`) };
+ const resolutionDirection = this.#direction(
+ this.data?.kpis?.resolution_rate
+ );
+ const replyDirection = this.#direction(this.data?.kpis?.avg_first_reply, {
+ noPriorDirection: "up",
+ });
+ if (
+ resolutionDirection === "unavailable" &&
+ replyDirection === "unavailable"
+ ) {
+ const headlineKeys = supportHeadlineKeys({ noData: true });
+ return {
+ title: i18n(`${prefix}.titles.${headlineKeys.title}`),
+ summary: i18n(`${prefix}.summaries.${headlineKeys.summary}`),
+ };
}
- const parts = [
- i18n(`${prefix}.resolution.${headline.resolution_direction}`, {
- rate: headline.resolution_rate,
- }),
- ];
+ const headlineKeys = supportHeadlineKeys({
+ resolutionRate: resolutionDirection,
+ firstReplyTime: replyDirection,
+ });
+ const summary = i18n(`${prefix}.summaries.${headlineKeys.summary}`);
+ const cta = headlineKeys.cta
+ ? i18n(`${prefix}.cta.${headlineKeys.cta}`)
+ : null;
+ return {
+ title: i18n(`${prefix}.titles.${headlineKeys.title}`),
+ summary: cta ? `${summary} ${cta}` : summary,
+ };
+ }
- if (headline.answerers_focus) {
- parts.push(
- i18n(`${prefix}.answerers.${headline.answerers_focus}`, {
- share: headline.answerers_share,
- })
- );
+ #direction(kpi, { noPriorDirection } = {}) {
+ if (kpi?.value == null) {
+ return "unavailable";
}
- if (headline.first_reply_seconds != null) {
- const dir = headline.first_reply_direction;
- if (
- (dir === "faster" || dir === "slower") &&
- headline.first_reply_delta_seconds != null
- ) {
- parts.push(
- i18n(`${prefix}.reply.${dir}`, {
- time: durationTiny(headline.first_reply_seconds),
- delta: durationTiny(headline.first_reply_delta_seconds),
- })
- );
- } else {
- parts.push(
- i18n(`${prefix}.reply.flat`, {
- time: durationTiny(headline.first_reply_seconds),
- })
- );
- }
+ if (kpi.previous_value == null && noPriorDirection) {
+ return noPriorDirection;
}
- if (headline.key === "struggling" && headline.unanswered_count > 0) {
- parts.push(
- i18n(`${prefix}.unanswered`, { count: headline.unanswered_count })
- );
+ const previousValue = kpi.previous_value ?? 0;
+ const roundedChange = Math.round(kpi.value - previousValue);
+ if (roundedChange > 0) {
+ return "up";
+ } else if (roundedChange < 0) {
+ return "down";
}
- return { titleKey, summary: parts.join(" ") };
+ return "flat";
}
get resolutionRate() {
@@ -339,7 +336,7 @@ export default class SupportSection extends Component {
{{#if this.headline}}
<div class="db-section__subheader">
<div class="db-section__subintro">
- <h3>{{i18n this.headline.titleKey}}</h3>
+ <h3>{{this.headline.title}}</h3>
<p>{{this.headline.summary}}</p>
</div>
diff --git a/plugins/discourse-solved/admin/assets/javascripts/admin/lib/support-headline.js b/plugins/discourse-solved/admin/assets/javascripts/admin/lib/support-headline.js
new file mode 100644
index 00000000000..15a4fd44309
--- /dev/null
+++ b/plugins/discourse-solved/admin/assets/javascripts/admin/lib/support-headline.js
@@ -0,0 +1,88 @@
+const HEADLINE_BY_SCENARIO = {
+ no_data: {
+ title: "insufficient_activity",
+ summary: "insufficient_activity",
+ },
+ "resolution_rate=up|first_reply_time=down": {
+ title: "resolution_rate_and_first_reply_time_improved",
+ summary: "more_answers_and_faster_replies",
+ },
+ "resolution_rate=up|first_reply_time=up": {
+ title: "resolution_rate_improved",
+ summary: "more_answers_but_slower_replies",
+ cta: "unanswered",
+ },
+ "resolution_rate=up|first_reply_time=flat": {
+ title: "resolution_rate_improved",
+ summary: "more_answers_first_reply_time_flat",
+ cta: "unanswered",
+ },
+ "resolution_rate=down|first_reply_time=down": {
+ title: "first_reply_time_decreased",
+ summary: "faster_replies_but_lower_resolution_rate",
+ cta: "in_progress",
+ },
+ "resolution_rate=flat|first_reply_time=down": {
+ title: "first_reply_time_decreased",
+ summary: "faster_replies_resolution_rate_steady",
+ cta: "in_progress",
+ },
+ "resolution_rate=down|first_reply_time=up": {
+ title: "resolution_rate_and_first_reply_time_declined",
+ summary: "fewer_answers_and_slower_replies",
+ cta: "in_progress_and_unanswered",
+ },
+ "resolution_rate=down|first_reply_time=flat": {
+ title: "resolution_rate_decreased",
+ summary: "fewer_answers_first_reply_time_steady",
+ cta: "in_progress",
+ },
+ "resolution_rate=flat|first_reply_time=up": {
+ title: "first_reply_time_increased",
+ summary: "slower_replies_resolution_rate_steady",
+ cta: "unanswered",
+ },
+ "resolution_rate=flat|first_reply_time=flat": {
+ title: "support_steady",
+ summary: "resolution_rate_and_first_reply_time_steady",
+ },
+ "resolution_rate=up|first_reply_time=unavailable": {
+ title: "resolution_rate_improved",
+ summary: "more_answers",
+ },
+ "resolution_rate=down|first_reply_time=unavailable": {
+ title: "resolution_rate_decreased",
+ summary: "fewer_answers",
+ cta: "in_progress",
+ },
+ "resolution_rate=flat|first_reply_time=unavailable": {
+ title: "support_steady",
+ summary: "resolution_rate_steady",
+ },
+ "resolution_rate=unavailable|first_reply_time=down": {
+ title: "first_reply_time_decreased",
+ summary: "faster_replies",
+ },
+ "resolution_rate=unavailable|first_reply_time=up": {
+ title: "first_reply_time_increased",
+ summary: "slower_replies",
+ cta: "unanswered",
+ },
+ "resolution_rate=unavailable|first_reply_time=flat": {
+ title: "support_steady",
+ summary: "first_reply_time_steady",
+ },
+};
+
+function scenarioKey({ resolutionRate, firstReplyTime, noData = false }) {
+ if (noData) {
+ return "no_data";
+ }
+
+ return `resolution_rate=${resolutionRate}|first_reply_time=${firstReplyTime}`;
+}
+
+export function supportHeadlineKeys(directions) {
+ const scenario = scenarioKey(directions);
+ return HEADLINE_BY_SCENARIO[scenario];
+}
diff --git a/plugins/discourse-solved/config/locales/client.en.yml b/plugins/discourse-solved/config/locales/client.en.yml
index cbde8167289..65b47d01545 100644
--- a/plugins/discourse-solved/config/locales/client.en.yml
+++ b/plugins/discourse-solved/config/locales/client.en.yml
@@ -16,29 +16,36 @@ en:
fetch_error: "Support data couldn't be loaded."
save_error: "Couldn't save your selection for next time."
headline:
- healthy:
- title: "The community is solving its own problems."
- struggling:
- title: "Most questions aren't getting answered."
- mixed:
- title: "Support is a mixed bag."
- no_data:
- title: "Not enough support activity yet"
- summary: "There's no support activity in this period yet. Once topics come in, you'll see how your community is handling them."
- resolution:
- up: "Resolution rate climbed to %{rate}%."
- down: "Resolution rate dropped to %{rate}%."
- flat: "Resolution rate held at %{rate}%."
- answerers:
- members: "Members are handling %{share}% of replies."
- staff: "Staff are answering %{share}% of replies."
- reply:
- faster: "First-reply time improved to %{time}, %{delta} faster than the previous period."
- slower: "First-reply time slipped to %{time}, %{delta} slower than the previous period."
- flat: "First-reply time held at %{time}."
- unanswered:
- one: "%{count} topic from this period still has zero replies."
- other: "%{count} topics from this period still have zero replies."
+ titles:
+ insufficient_activity: "Not enough support activity yet"
+ resolution_rate_and_first_reply_time_improved: "Resolution rate and time to first reply have improved in the selected period"
+ resolution_rate_improved: "The resolution rate has improved in the selected period"
+ first_reply_time_decreased: "The time to first reply has decreased in the selected period"
+ resolution_rate_and_first_reply_time_declined: "Resolution rate and time to first reply have declined in the selected period"
+ resolution_rate_decreased: "The resolution rate has decreased in the selected period"
+ first_reply_time_increased: "The time to first reply has increased in the selected period"
+ support_steady: "Support is steady in the selected period"
+ summaries:
+ insufficient_activity: "There's no support activity in this period yet. Once topics come in, you'll see how your community is handling them."
+ more_answers_and_faster_replies: "More questions are getting answered, and they're getting answered faster."
+ more_answers_but_slower_replies: "More questions are getting answered, but the time to first reply has increased."
+ more_answers_first_reply_time_flat: "More questions are getting answered, but the time to first reply is flat."
+ faster_replies_but_lower_resolution_rate: "Members are getting faster responses, but resolution rate has decreased."
+ faster_replies_resolution_rate_steady: "Members are getting faster responses, but resolution rate is flat."
+ fewer_answers_and_slower_replies: "Members are getting fewer answers and are waiting longer for their first reply."
+ fewer_answers_first_reply_time_steady: "Members are getting fewer answers, but the time to first reply is holding steady."
+ slower_replies_resolution_rate_steady: "Members are waiting longer for their first reply, but the resolution rate is holding steady."
+ resolution_rate_and_first_reply_time_steady: "No meaningful change in resolution rate or time to first reply."
+ more_answers: "More questions are getting answered."
+ fewer_answers: "Members are getting fewer answers."
+ resolution_rate_steady: "No meaningful change in resolution rate."
+ faster_replies: "Members are getting faster responses."
+ slower_replies: "Members are waiting longer for their first reply."
+ first_reply_time_steady: "No meaningful change in time to first reply."
+ cta:
+ unanswered: "Check out the unanswered topics to see which you can address."
+ in_progress: "Take a look at the in progress topics to see if there are replies that should be marked as answers."
+ in_progress_and_unanswered: "Investigate the in progress and unanswered topics to make sure members are getting timely responses."
kpi:
resolution_rate:
label: "Resolution rate"
diff --git a/plugins/discourse-solved/lib/discourse_solved/admin_dashboard_support.rb b/plugins/discourse-solved/lib/discourse_solved/admin_dashboard_support.rb
index 1f0b011a8c4..e82508bf4cc 100644
--- a/plugins/discourse-solved/lib/discourse_solved/admin_dashboard_support.rb
+++ b/plugins/discourse-solved/lib/discourse_solved/admin_dashboard_support.rb
@@ -54,7 +54,6 @@ module DiscourseSolved
category_options: category_options,
category_ids: selected_category_ids,
kpis: build_kpis,
- headline: build_headline,
topic_outcomes: topic_outcomes,
whos_answering: whos_answering,
response_time_distribution: response_time_distribution,
@@ -155,48 +154,6 @@ module DiscourseSolved
query
end
- def build_headline
- outcomes = topic_outcomes
- total = outcomes.values.sum
- rate = resolution_rate(outcomes)
- prev_rate = resolution_rate(outcomes_for(prev_start_date, prev_end_date))
-
- key =
- if total.zero?
- "no_data"
- elsif rate >= 60
- "healthy"
- elsif rate < 40
- "struggling"
- else
- "mixed"
- end
-
- reply_now = avg_first_reply_seconds(start_date, end_date)
- reply_prev = avg_first_reply_seconds(prev_start_date, prev_end_date)
-
- answerers = whos_answering
- staff_share =
- if answerers[:total].to_i.zero?
- nil
- else
- (answerers[:rows].find { |r| r[:type] == "staff" }&.dig(:share) || 0).round
- end
- focus = staff_share.nil? ? nil : (staff_share >= 50 ? "staff" : "members")
-
- {
- key: key,
- resolution_rate: rate&.round,
- resolution_direction: direction(rate, prev_rate),
- answerers_focus: focus,
- answerers_share: (focus == "staff" ? staff_share : (staff_share && 100 - staff_share)),
- first_reply_seconds: reply_now,
- first_reply_direction: time_direction(reply_now, reply_prev),
- first_reply_delta_seconds: (reply_now && reply_prev ? (reply_now - reply_prev).abs : nil),
- unanswered_count: outcomes[:unanswered],
- }
- end
-
# Mutually-exclusive status counts for topics created in the window:
# resolved (has an accepted answer), else in_progress (has at least one
# reply), else unanswered.
@@ -403,11 +360,6 @@ module DiscourseSolved
}
end
- def direction(current, previous)
- return "flat" if current.nil? || previous.nil? || current == previous
- current > previous ? "up" : "down"
- end
-
# For durations, lower is better, so "faster"/"slower" rather than up/down.
def time_direction(current, previous)
return "flat" if current.nil? || previous.nil? || current == previous
diff --git a/plugins/discourse-solved/spec/lib/discourse_solved/admin_dashboard_support_spec.rb b/plugins/discourse-solved/spec/lib/discourse_solved/admin_dashboard_support_spec.rb
index f2c85123373..0ed48368330 100644
--- a/plugins/discourse-solved/spec/lib/discourse_solved/admin_dashboard_support_spec.rb
+++ b/plugins/discourse-solved/spec/lib/discourse_solved/admin_dashboard_support_spec.rb
@@ -101,42 +101,6 @@ RSpec.describe DiscourseSolved::AdminDashboardSupport do
end
end
- describe "headline" do
- it "chooses the key from the absolute resolution rate, not the trend" do
- solved_topic
- unanswered_topic
- another_unanswered_topic
-
- expect(dashboard[:headline][:key]).to eq("struggling")
- end
-
- it "reports the resolution direction against the previous period, independent of the level" do
- previous =
- Fabricate(:topic, category: support_category, user: author, created_at: 45.days.ago)
- Fabricate(:post, topic: previous, user: author, created_at: 45.days.ago)
-
- solved_topic
- unanswered_topic
- another_unanswered_topic
-
- headline = dashboard[:headline]
- expect(headline[:key]).to eq("struggling")
- expect(headline[:resolution_direction]).to eq("up")
- end
-
- it "focuses the answerers clause on staff when staff dominate replies" do
- solved_topic
-
- expect(dashboard[:headline][:answerers_focus]).to eq("staff")
- end
-
- it "focuses the answerers clause on members when non-staff dominate replies" do
- answered_topic
-
- expect(dashboard[:headline][:answerers_focus]).to eq("members")
- end
- end
-
describe "resolution rate KPI" do
it "is the share of period topics that were solved" do
solved_topic
diff --git a/plugins/discourse-solved/spec/system/admin_dashboard_support_section_spec.rb b/plugins/discourse-solved/spec/system/admin_dashboard_support_section_spec.rb
index dd99270b479..a0a2a544493 100644
--- a/plugins/discourse-solved/spec/system/admin_dashboard_support_section_spec.rb
+++ b/plugins/discourse-solved/spec/system/admin_dashboard_support_section_spec.rb
@@ -36,6 +36,11 @@ describe "Admin dashboard Support section" do
dashboard.visit
expect(support).to have_section
+ expect(support).to have_headline(
+ "The resolution rate has improved in the selected period",
+ "More questions are getting answered, but the time to first reply has increased. Check " \
+ "out the unanswered topics to see which you can address.",
+ )
expect(support).to have_kpi("Resolution rate")
expect(support).to have_kpi("Staff involvement")
expect(support).to have_kpi("Avg. first reply")
diff --git a/plugins/discourse-solved/spec/system/page_objects/components/admin_dashboard_support.rb b/plugins/discourse-solved/spec/system/page_objects/components/admin_dashboard_support.rb
index 388c4ef1833..42d9deac42f 100644
--- a/plugins/discourse-solved/spec/system/page_objects/components/admin_dashboard_support.rb
+++ b/plugins/discourse-solved/spec/system/page_objects/components/admin_dashboard_support.rb
@@ -13,8 +13,9 @@ module PageObjects
has_no_css?(SELECTOR)
end
- def has_headline?(text)
- has_css?("#{SELECTOR} .db-section__subintro h3", text: text)
+ def has_headline?(title, summary)
+ has_css?("#{SELECTOR} .db-section__subintro h3", exact_text: title) &&
+ has_css?("#{SELECTOR} .db-section__subintro p", exact_text: summary)
end
def has_kpi?(label)
diff --git a/plugins/discourse-solved/test/javascripts/integration/support-test.gjs b/plugins/discourse-solved/test/javascripts/integration/support-test.gjs
index 0e90a2e2a61..a84ebffa03d 100644
--- a/plugins/discourse-solved/test/javascripts/integration/support-test.gjs
+++ b/plugins/discourse-solved/test/javascripts/integration/support-test.gjs
@@ -1,4 +1,4 @@
-import { render } from "@ember/test-helpers";
+import { find, render } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import selectKit from "discourse/tests/helpers/select-kit-helper";
@@ -17,17 +17,6 @@ function buildData(overrides = {}) {
staff_involvement: { value: 19, previous_value: 25 },
avg_first_reply: { value: 11100, previous_value: 10620 },
},
- headline: {
- key: "healthy",
- resolution_rate: 72,
- resolution_direction: "up",
- answerers_focus: "members",
- answerers_share: 82,
- first_reply_seconds: 11100,
- first_reply_direction: "slower",
- first_reply_delta_seconds: 480,
- unanswered_count: 3,
- },
topic_outcomes: { resolved: 1, in_progress: 0, unanswered: 3 },
whos_answering: {
rows: [{ type: "staff", count: 1, share: 100 }],
@@ -48,7 +37,6 @@ function buildData(overrides = {}) {
const startDate = new Date("2026-04-01");
const endDate = new Date("2026-04-30");
-
module("Integration | Component | Dashboard | Support", function (hooks) {
setupRenderingTest(hooks);
@@ -140,52 +128,51 @@ module("Integration | Component | Dashboard | Support", function (hooks) {
assert.dom(".db-section__metrics .db-pill").doesNotExist();
});
- test("composes a trend-aware headline summary from each metric's direction", async function (assert) {
- const positive = buildData();
-
- await render(
- <template>
- <SupportSection
- @data={{positive}}
- @startDate={{startDate}}
- @endDate={{endDate}}
- />
- </template>
- );
-
- assert.dom(".db-section__subintro p").includesText("climbed to 72%");
- assert
- .dom(".db-section__subintro p")
- .includesText("Members are handling 82%");
-
- const negative = buildData({
- headline: {
- key: "struggling",
- resolution_rate: 34,
- resolution_direction: "down",
- answerers_focus: "staff",
- answerers_share: 81,
- first_reply_seconds: 51720,
- first_reply_direction: "slower",
- first_reply_delta_seconds: 31200,
- unanswered_count: 47,
+ test("shows declining support when resolution drops and first reply slows", async function (assert) {
+ const data = {
+ category_options: [],
+ kpis: {
+ resolution_rate: { value: 48, previous_value: 60, report_query: {} },
+ staff_involvement: { value: 19, previous_value: 25 },
+ avg_first_reply: { value: 15_000, previous_value: 12_000 },
},
- });
+ topic_outcomes: { resolved: 1, in_progress: 0, unanswered: 3 },
+ whos_answering: {
+ rows: [{ type: "staff", count: 1, share: 100 }],
+ total: 1,
+ },
+ response_time_distribution: {
+ buckets: [
+ { key: "lt_1h", count: 1, share: 100 },
+ { key: "1_4h", count: 0, share: 0 },
+ { key: "4_24h", count: 0, share: 0 },
+ { key: "gt_24h", count: 0, share: 0 },
+ ],
+ trend: { direction: "flat", seconds: 0 },
+ },
+ };
await render(
<template>
<SupportSection
- @data={{negative}}
+ @data={{data}}
+ @period="custom"
@startDate={{startDate}}
@endDate={{endDate}}
/>
</template>
);
-
- assert.dom(".db-section__subintro p").includesText("dropped to 34%");
- assert
- .dom(".db-section__subintro p")
- .includesText("47 topics from this period still have zero replies");
+ assert.deepEqual(
+ [
+ find(".db-section__subintro h3").textContent.trim(),
+ find(".db-section__subintro p").textContent.trim(),
+ ],
+ [
+ "Resolution rate and time to first reply have declined in the selected period",
+ "Members are getting fewer answers and are waiting longer for their first reply. Investigate the in progress and unanswered topics to make sure members are getting timely responses.",
+ ],
+ "renders the exact scenario headline and summary"
+ );
});
test("shows a placeholder when the average first reply is unknown", async function (assert) {
@@ -426,4 +413,95 @@ module("Integration | Component | Dashboard | Support", function (hooks) {
"the count stays exposed to assistive tech"
);
});
+
+ test("summarizes the measurable metric when reply time is unavailable", async function (assert) {
+ const data = {
+ category_options: [],
+ kpis: {
+ resolution_rate: { value: 72, previous_value: 60, report_query: {} },
+ staff_involvement: { value: null, previous_value: null },
+ avg_first_reply: { value: null, previous_value: null },
+ },
+ topic_outcomes: { resolved: 1, in_progress: 0, unanswered: 0 },
+ whos_answering: { rows: [], total: 0 },
+ response_time_distribution: {
+ buckets: [],
+ trend: { direction: "flat", seconds: 0 },
+ },
+ };
+
+ await render(
+ <template>
+ <SupportSection @data={{data}} @period="last_30_days" />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro")
+ .hasText(
+ "The resolution rate has improved in the selected period More questions are getting answered."
+ );
+ });
+
+ test("shows improved resolution and slower replies when the prior period has no support activity", async function (assert) {
+ const data = {
+ category_options: [],
+ kpis: {
+ resolution_rate: {
+ value: 72,
+ previous_value: null,
+ report_query: {},
+ },
+ staff_involvement: { value: 50, previous_value: null },
+ avg_first_reply: { value: 0, previous_value: null },
+ },
+ topic_outcomes: { resolved: 1, in_progress: 0, unanswered: 0 },
+ whos_answering: { rows: [], total: 0 },
+ response_time_distribution: {
+ buckets: [],
+ trend: { direction: "flat", seconds: 0 },
+ },
+ };
+
+ await render(
+ <template>
+ <SupportSection @data={{data}} @period="last_30_days" />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro")
+ .hasText(
+ "The resolution rate has improved in the selected period More questions are getting answered, but the time to first reply has increased. Check out the unanswered topics to see which you can address."
+ );
+ });
+
+ test("shows the no-data message when no metric is measurable", async function (assert) {
+ const data = {
+ category_options: [],
+ kpis: {
+ resolution_rate: { value: null, previous_value: null },
+ staff_involvement: { value: null, previous_value: null },
+ avg_first_reply: { value: null, previous_value: null },
+ },
+ topic_outcomes: { resolved: 0, in_progress: 0, unanswered: 0 },
+ whos_answering: { rows: [], total: 0 },
+ response_time_distribution: {
+ buckets: [],
+ trend: { direction: "flat", seconds: 0 },
+ },
+ };
+
+ await render(
+ <template>
+ <SupportSection @data={{data}} @period="last_30_days" />
+ </template>
+ );
+
+ assert
+ .dom(".db-section__subintro")
+ .hasText(
+ "Not enough support activity yet There's no support activity in this period yet. Once topics come in, you'll see how your community is handling them."
+ );
+ });
});
diff --git a/spec/requests/admin/dashboard_controller_spec.rb b/spec/requests/admin/dashboard_controller_spec.rb
index 18fea810156..7fd6953059d 100644
--- a/spec/requests/admin/dashboard_controller_spec.rb
+++ b/spec/requests/admin/dashboard_controller_spec.rb
@@ -336,13 +336,14 @@ RSpec.describe Admin::DashboardController do
expect(response.status).to eq(200)
expect(search_data).to eq(
"logging_enabled" => true,
- "headline_state" => "healthy",
"kpis" => {
"total_searches" => {
"value" => 2,
+ "previous_value" => 0,
},
"no_result_rate" => {
"value" => 0,
+ "previous_value" => nil,
"exceeds_threshold" => false,
},
},
@@ -457,7 +458,7 @@ RSpec.describe Admin::DashboardController do
get "/admin/dashboard.json"
engagement = response.parsed_body["sections"].find { |s| s["id"] == "engagement" }
- expect(engagement["data"]).to include("kpis", "headline")
+ expect(engagement["data"]).to include("kpis")
end
describe "reports section data" do
diff --git a/spec/services/admin_dashboard_engagement_spec.rb b/spec/services/admin_dashboard_engagement_spec.rb
index bf7dbbd0266..54c520f6edc 100644
--- a/spec/services/admin_dashboard_engagement_spec.rb
+++ b/spec/services/admin_dashboard_engagement_spec.rb
@@ -73,7 +73,6 @@ describe AdminDashboardEngagement do
expect(engaged[:value]).to eq(1.0)
expect(engaged[:previous_value]).to eq(4.0)
expect(engaged[:percent_change]).to eq(-75.0)
- expect(result[:headline][:key]).not_to end_with("healthy_growth")
end
it "falls back to a default 30-day window when params are blank" do
@@ -376,56 +375,5 @@ describe AdminDashboardEngagement do
expect(pipeline[:total_members]).to be >= 2
end
end
-
- describe "headline" do
- def stub_kpis(signups:, dau: 0, engaged: 0)
- described_class
- .any_instance
- .stubs(:build_kpis)
- .returns(
- [
- { type: :dau_mau, percent_change: dau },
- { type: :new_signups, percent_change: signups },
- { type: :daily_engaged_users, percent_change: engaged },
- ],
- )
- end
-
- it "returns healthy_growth when every metric is non-negative and at least one is positive" do
- stub_kpis(signups: 12, dau: 3, engaged: 5)
- result = described_class.build(start_date: "2026-04-01", end_date: "2026-04-28")
- expect(result[:headline][:key]).to end_with("healthy_growth")
- end
-
- it "returns declining when every metric is non-positive and at least one is negative" do
- stub_kpis(signups: -8, dau: -2, engaged: -5)
- result = described_class.build(start_date: "2026-04-01", end_date: "2026-04-28")
- expect(result[:headline][:key]).to end_with("declining")
- end
-
- it "returns engaged_but_shrinking when stickiness is up but engagement or signups fell" do
- stub_kpis(signups: -5, dau: 2, engaged: -3)
- result = described_class.build(start_date: "2026-04-01", end_date: "2026-04-28")
- expect(result[:headline][:key]).to end_with("engaged_but_shrinking")
- end
-
- it "returns growing_but_distracted when sign-ups rose but stickiness slipped" do
- stub_kpis(signups: 10, dau: -4, engaged: 0)
- result = described_class.build(start_date: "2026-04-01", end_date: "2026-04-28")
- expect(result[:headline][:key]).to end_with("growing_but_distracted")
- end
-
- it "returns no_signal when every metric has no change" do
- stub_kpis(signups: 0, dau: 0, engaged: 0)
- result = described_class.build(start_date: "2026-04-01", end_date: "2026-04-28")
- expect(result[:headline][:key]).to end_with("no_signal")
- end
-
- it "returns mixed when stickiness fell, sign-ups flat, but engagement rose" do
- stub_kpis(signups: 0, dau: -3, engaged: 4)
- result = described_class.build(start_date: "2026-04-01", end_date: "2026-04-28")
- expect(result[:headline][:key]).to end_with("mixed")
- end
- end
end
end
diff --git a/spec/services/admin_dashboard_search_spec.rb b/spec/services/admin_dashboard_search_spec.rb
index 0ed8fc4c3a8..bd41283cecf 100644
--- a/spec/services/admin_dashboard_search_spec.rb
+++ b/spec/services/admin_dashboard_search_spec.rb
@@ -73,14 +73,15 @@ RSpec.describe AdminDashboardSearch do
)
expect(described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")).to eq(
logging_enabled: true,
- headline_state: "content_gaps",
kpis: {
total_searches: {
value: 19,
+ previous_value: 10,
percent_change: 90,
},
no_result_rate: {
value: 21,
+ previous_value: 50,
point_change: -29,
exceeds_threshold: true,
},
@@ -155,13 +156,14 @@ RSpec.describe AdminDashboardSearch do
expect(described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")).to eq(
logging_enabled: true,
- headline_state: "healthy",
kpis: {
total_searches: {
value: 136,
+ previous_value: 0,
},
no_result_rate: {
value: 4,
+ previous_value: nil,
exceeds_threshold: false,
},
},
@@ -194,13 +196,14 @@ RSpec.describe AdminDashboardSearch do
expect(described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")).to eq(
logging_enabled: true,
- headline_state: "content_gaps",
kpis: {
total_searches: {
value: 11,
+ previous_value: 0,
},
no_result_rate: {
value: 100,
+ previous_value: nil,
exceeds_threshold: true,
},
},
@@ -213,108 +216,6 @@ RSpec.describe AdminDashboardSearch do
)
end
- it "picks the headline state from the rate and volume signals" do
- Fabricate(:search_log, term: "ghost", user: user, created_at: "2026-05-02 10:00")
- Fabricate.times(
- 11,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2026-05-02 11:00",
- )
- Fabricate.times(
- 12,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2026-04-26 10:00",
- )
-
- Fabricate.times(
- 4,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2026-04-02 10:00",
- )
- Fabricate.times(
- 10,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2026-03-27 10:00",
- )
-
- Fabricate.times(
- 12,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2026-03-02 10:00",
- )
- Fabricate.times(
- 10,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2026-02-24 10:00",
- )
-
- expect(
- described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")[:headline_state],
- ).to eq("rate_climbing")
-
- expect(
- described_class.build(start_date: "2026-04-01", end_date: "2026-04-07")[:headline_state],
- ).to eq("shrinking")
-
- expect(
- described_class.build(start_date: "2026-03-01", end_date: "2026-03-07")[:headline_state],
- ).to eq("healthy")
- end
-
- it "resolves overlapping headline states by priority" do
- Fabricate.times(3, :search_log, term: "ghost", user: user, created_at: "2026-02-02 10:00")
- Fabricate.times(
- 7,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2026-02-02 11:00",
- )
- Fabricate.times(
- 10,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2026-01-27 10:00",
- )
-
- Fabricate(:search_log, term: "ghost", user: user, created_at: "2026-01-02 10:00")
- Fabricate.times(
- 9,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2026-01-02 11:00",
- )
- Fabricate.times(
- 20,
- :clicked_search_log,
- term: "ruby",
- user: user,
- created_at: "2025-12-27 10:00",
- )
-
- expect(
- described_class.build(start_date: "2026-02-01", end_date: "2026-02-07")[:headline_state],
- ).to eq("content_gaps")
-
- expect(
- described_class.build(start_date: "2026-01-01", end_date: "2026-01-07")[:headline_state],
- ).to eq("rate_climbing")
- end
-
it "omits deltas when the prior window has no searches" do
Fabricate.times(
2,
@@ -327,9 +228,11 @@ RSpec.describe AdminDashboardSearch do
expect(described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")[:kpis]).to eq(
total_searches: {
value: 2,
+ previous_value: 0,
},
no_result_rate: {
value: 0,
+ previous_value: nil,
exceeds_threshold: false,
},
)
@@ -340,13 +243,14 @@ RSpec.describe AdminDashboardSearch do
expect(described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")).to eq(
logging_enabled: true,
- headline_state: "no_signal",
kpis: {
total_searches: {
value: 0,
+ previous_value: 2,
},
no_result_rate: {
value: nil,
+ previous_value: 100,
exceeds_threshold: false,
},
},
@@ -375,9 +279,11 @@ RSpec.describe AdminDashboardSearch do
expect(described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")[:kpis]).to eq(
total_searches: {
value: 5,
+ previous_value: 5,
},
no_result_rate: {
value: 0,
+ previous_value: 0,
exceeds_threshold: false,
},
)
@@ -405,10 +311,12 @@ RSpec.describe AdminDashboardSearch do
expect(described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")[:kpis]).to eq(
total_searches: {
value: 4,
+ previous_value: 10,
percent_change: -60,
},
no_result_rate: {
value: 25,
+ previous_value: 10,
point_change: 15,
exceeds_threshold: true,
},
@@ -429,7 +337,7 @@ RSpec.describe AdminDashboardSearch do
described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")[:kpis][
:no_result_rate
],
- ).to eq(value: 10, exceeds_threshold: false)
+ ).to eq(value: 10, previous_value: nil, exceeds_threshold: false)
end
it "flags a rate just above 10% even when the display rounds to 10%" do
@@ -446,7 +354,7 @@ RSpec.describe AdminDashboardSearch do
described_class.build(start_date: "2026-05-01", end_date: "2026-05-07")[:kpis][
:no_result_rate
],
- ).to eq(value: 10, exceeds_threshold: true)
+ ).to eq(value: 10, previous_value: nil, exceeds_threshold: true)
end
it "maps the window length to the per-term report period" do
diff --git a/spec/system/admin_dashboard_redesign/engagement_section_spec.rb b/spec/system/admin_dashboard_redesign/engagement_section_spec.rb
index c29279d8e41..60c13afbad4 100644
--- a/spec/system/admin_dashboard_redesign/engagement_section_spec.rb
+++ b/spec/system/admin_dashboard_redesign/engagement_section_spec.rb
@@ -115,4 +115,40 @@ describe "Admin Dashboard Redesign | Engagement section" do
expect(engagement).to have_no_selected_whos_posting_category(category_alpha)
end
+
+ it "shows that engagement is up when every engagement metric improves",
+ time: Time.zone.local(2026, 6, 15, 12, 0, 0) do
+ Fabricate(:user_visit_daily_rollup, date: Date.new(2026, 5, 1), dau: 1, mau: 2)
+ Fabricate(:user_visit_daily_rollup, date: Date.new(2026, 6, 1), dau: 2, mau: 2)
+
+ prior_engaged_user = Fabricate(:user, created_at: Time.zone.local(2026, 1, 1))
+ Fabricate(
+ :user_action,
+ user: prior_engaged_user,
+ action_type: UserAction::LIKE,
+ created_at: Time.zone.local(2026, 5, 1),
+ )
+
+ 2.times do
+ current_engaged_user = Fabricate(:user, created_at: Time.zone.local(2026, 1, 1))
+ Fabricate(
+ :user_action,
+ user: current_engaged_user,
+ action_type: UserAction::LIKE,
+ created_at: Time.zone.local(2026, 6, 1),
+ )
+ end
+
+ Fabricate(:user, created_at: Time.zone.local(2026, 5, 1))
+ Fabricate.times(2, :user, created_at: Time.zone.local(2026, 6, 1))
+ Discourse.cache.clear
+
+ dashboard.visit
+
+ expect(engagement).to have_headline(
+ "Engagement is up in the selected period",
+ "Stickiness, daily engagement, and new signups have all improved, showing that more " \
+ "members are joining and participating in your community.",
+ )
+ end
end
diff --git a/spec/system/admin_dashboard_redesign/search_section_spec.rb b/spec/system/admin_dashboard_redesign/search_section_spec.rb
index 42c2797606f..f37b0b57970 100644
--- a/spec/system/admin_dashboard_redesign/search_section_spec.rb
+++ b/spec/system/admin_dashboard_redesign/search_section_spec.rb
@@ -88,9 +88,9 @@ describe "Admin Dashboard Redesign | Search section" do
search = dashboard.search
expect(search).to have_headline(
- "Members ran 50 on-site searches in the last 30 days",
- "The no-result rate is climbing compared with the previous period. " \
- "Keep an eye on the content gaps below.",
+ "The total number of searches has increased in the selected period",
+ "Members are conducting more searches in your community, but the no-result rate has " \
+ "increased. Review the content gaps to see what's missing.",
)
expect(search).to have_total_searches_kpi("50", improving_delta: "+25%")
@@ -140,8 +140,9 @@ describe "Admin Dashboard Redesign | Search section" do
dashboard.select_preset("last_7_days")
expect(search).to have_headline(
- "Members ran 27 on-site searches in the last 7 days",
- "Members keep finding what they search for, and search volume is steady or growing.",
+ "Searches have increased and the no-result rate has declined in the selected period",
+ "Members are conducting more searches in your community and are finding what they're " \
+ "looking for more often.",
)
expect(search).to have_total_searches_kpi("27", improving_delta: "+800%")
@@ -160,8 +161,9 @@ describe "Admin Dashboard Redesign | Search section" do
dashboard.select_preset("last_3_months")
expect(dashboard.search).to have_headline(
- "Members ran 90 on-site searches in the last 3 months",
- "Members keep finding what they search for, and search volume is steady or growing.",
+ "The total number of searches has increased in the selected period",
+ "Members are conducting more searches in your community, but the no-result rate has " \
+ "increased. Review the content gaps to see what's missing.",
)
dashboard.search.click_content_gap_term("discobot")
@@ -184,9 +186,9 @@ describe "Admin Dashboard Redesign | Search section" do
search = dashboard.search
expect(search).to have_headline(
- "Members ran 10 on-site searches in the last 30 days",
- "More than 10% of member searches ended without a click this period. " \
- "Review the content gaps below to see what's missing.",
+ "The total number of searches has increased in the selected period",
+ "Members are conducting more searches in your community, but the no-result rate has " \
+ "increased. Review the content gaps to see what's missing.",
)
expect(search).to have_total_searches_kpi("10")
expect(search).to have_alert_no_result_rate_kpi("50%")
@@ -244,9 +246,8 @@ describe "Admin Dashboard Redesign | Search section" do
search = dashboard.search
expect(search).to have_headline(
- "Members ran 3 on-site searches in the selected period",
- "Search volume is down compared with the previous period, " \
- "while most searches still lead to content.",
+ "The no-result rate has decreased in the selected period",
+ "Members are finding what they're looking for, and total search volume has decreased.",
)
expect(search).to have_total_searches_kpi("3", worsening_delta: "-40%")
expect(search).to have_no_result_rate_kpi("0%", improving_delta: "-100%")
@@ -264,9 +265,9 @@ describe "Admin Dashboard Redesign | Search section" do
dashboard.visit_with_query(range: "custom", start_date: "2026-04-25", end_date: "2026-04-25")
expect(search).to have_headline(
- "Members ran 1 on-site search in the selected period",
- "More than 10% of member searches ended without a click this period. " \
- "Review the content gaps below to see what's missing.",
+ "The total number of searches has increased in the selected period",
+ "Members are conducting more searches in your community, but the no-result rate has " \
+ "increased. Review the content gaps to see what's missing.",
)
end
end
diff --git a/spec/system/page_objects/components/admin_dashboard_engagement.rb b/spec/system/page_objects/components/admin_dashboard_engagement.rb
index 8d1767ba2cc..ec5bef9c88c 100644
--- a/spec/system/page_objects/components/admin_dashboard_engagement.rb
+++ b/spec/system/page_objects/components/admin_dashboard_engagement.rb
@@ -68,6 +68,11 @@ module PageObjects
def has_no_selected_whos_posting_category?(category)
has_no_css?("#{WHOS_POSTING_CATEGORY_FILTER} .selected-choice[data-value='#{category.id}']")
end
+
+ def has_headline?(title, summary)
+ has_css?("#{SECTION} .db-section__subintro h3", exact_text: title) &&
+ has_css?("#{SECTION} .db-section__subintro p", exact_text: summary)
+ end
end
end
end