From 17c133bac01150642714a60e8b2b30f65fab5cf0 Mon Sep 17 00:00:00 2001 From: corsacca Date: Fri, 22 May 2026 16:20:35 +0100 Subject: [PATCH] stats use total_unengaged for homepage count, keep total on pray/adopt proxy total_unengaged through people-groups statistics endpoint add unengagedPeopleGroups computeds to usePrayerStatistics point homepage "unengaged people groups" copy at total_unengaged pray/adopt denominators and progress bars stay on full total --- app/composables/usePrayerStatistics.ts | 14 ++++++++++++++ app/pages/index.vue | 8 ++++---- server/api/people-groups/statistics.get.ts | 7 +++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/composables/usePrayerStatistics.ts b/app/composables/usePrayerStatistics.ts index 2ad7df48..47050d50 100644 --- a/app/composables/usePrayerStatistics.ts +++ b/app/composables/usePrayerStatistics.ts @@ -10,6 +10,7 @@ export interface PrayerStatistics { total: number + total_unengaged: number total_with_prayer: number total_with_full_prayer: number total_adopted: number @@ -25,6 +26,7 @@ export function usePrayerStatistics() { const stats = useState('prayer-stats', () => ({ total: 0, + total_unengaged: 0, total_with_prayer: 0, total_with_full_prayer: 0, total_adopted: 0 @@ -39,6 +41,7 @@ export function usePrayerStatistics() { const data = await $fetch('/api/people-groups/statistics') stats.value = { total: Number(data.total || 0), + total_unengaged: Number(data.total_unengaged || 0), total_with_prayer: Number(data.total_with_prayer || 0), total_with_full_prayer: Number(data.total_with_full_prayer || 0), total_adopted: Number(data.total_adopted || 0) @@ -60,6 +63,7 @@ export function usePrayerStatistics() { const data = await $fetch('/api/people-groups/statistics') stats.value = { total: Number(data.total || 0), + total_unengaged: Number(data.total_unengaged || 0), total_with_prayer: Number(data.total_with_prayer || 0), total_with_full_prayer: Number(data.total_with_full_prayer || 0), total_adopted: Number(data.total_adopted || 0) @@ -78,6 +82,14 @@ export function usePrayerStatistics() { totalPeopleGroups.value.toLocaleString(`${locale.value}-u-nu-latn`) ) + // The unengaged subset of people groups, used where the copy specifically + // says "unengaged" (the homepage). The pray/adopt pages use the full + // `totalPeopleGroups` total above instead. + const unengagedPeopleGroups = computed(() => stats.value.total_unengaged || FALLBACK_TOTAL) + const unengagedPeopleGroupsFormatted = computed(() => + unengagedPeopleGroups.value.toLocaleString(`${locale.value}-u-nu-latn`) + ) + const prayerCoveragePercent = computed( () => Math.min(100, (stats.value.total_with_full_prayer / totalPeopleGroups.value) * 100) ) @@ -91,6 +103,8 @@ export function usePrayerStatistics() { error: readonly(error), totalPeopleGroups, totalPeopleGroupsFormatted, + unengagedPeopleGroups, + unengagedPeopleGroupsFormatted, prayerCoveragePercent, adoptedPercent, reload, diff --git a/app/pages/index.vue b/app/pages/index.vue index 4fa9aa24..512387fc 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -19,7 +19,7 @@ function openVideo() { videoModalRef.value?.open() } -const { totalPeopleGroupsFormatted, ensureLoaded } = usePrayerStatistics() +const { unengagedPeopleGroupsFormatted, ensureLoaded } = usePrayerStatistics() await ensureLoaded() const mapboxToken = config.public.mapboxToken as string @@ -121,7 +121,7 @@ useTextHighlight()

- {{ t('{0} unengaged people groups', [totalPeopleGroupsFormatted]) }} + {{ t('{0} unengaged people groups', [unengagedPeopleGroupsFormatted]) }}

{{ t('Our hope is to see each of them covered in 24-hour prayer, and your church can be part of it.') }} @@ -206,7 +206,7 @@ useTextHighlight()

{{ t('Unengaged') }}

{{ t('{0} Million', ['202']) }} - {{ t('{0} People Groups', [totalPeopleGroupsFormatted]) }} + {{ t('{0} People Groups', [unengagedPeopleGroupsFormatted]) }}
@@ -250,7 +250,7 @@ useTextHighlight()

{{ t('In partnership with the global church, our vision is for...') }}

    -
  • {{ t('Daily 24-hour prayer coverage for all {0} unengaged peoples', [totalPeopleGroupsFormatted]) }}
  • +
  • {{ t('Daily 24-hour prayer coverage for all {0} unengaged peoples', [unengagedPeopleGroupsFormatted]) }}
  • {{ t('No unengaged people groups by 2033') }}
  • {{ t('Mobilization of 20,000+ DOXA partnership missionaries') }}
  • {{ t('Fruitful engagement among frontier peoples and the under-engaged') }}
  • diff --git a/server/api/people-groups/statistics.get.ts b/server/api/people-groups/statistics.get.ts index ea618afe..e1313b6c 100644 --- a/server/api/people-groups/statistics.get.ts +++ b/server/api/people-groups/statistics.get.ts @@ -1,13 +1,15 @@ // Server-side cached proxy to campaigns-sever's `/api/people-groups/statistics`. // The composable `usePrayerStatistics` calls this so the upstream is only hit -// once per cache window per server instance — and so `total` (the live count -// of people groups) can drive the denominator that used to be hardcoded as +// once per cache window per server instance — and so the live `total` (all +// people groups, used by the pray/adopt denominators) and `total_unengaged` +// (the homepage count) can drive the numbers that used to be hardcoded as // 2,085 in templates. import { defineCachedEventHandler } from 'nitropack/runtime' export interface PrayerStatisticsResponse { total: number + total_unengaged: number total_with_prayer: number total_with_full_prayer: number total_adopted: number @@ -25,6 +27,7 @@ export default defineCachedEventHandler( ) return { total: Number(data.total || 0), + total_unengaged: Number(data.total_unengaged || 0), total_with_prayer: Number(data.total_with_prayer || 0), total_with_full_prayer: Number(data.total_with_full_prayer || 0), total_adopted: Number(data.total_adopted || 0),