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
This commit is contained in:
corsacca 2026-05-22 16:20:35 +01:00
parent 314a1b9eee
commit 17c133bac0
3 changed files with 23 additions and 6 deletions

View file

@ -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<PrayerStatistics>('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<PrayerStatistics>('/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<PrayerStatistics>('/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,

View file

@ -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()
<div class="container stack stack--4xl">
<div class="stack stack--2xl">
<h2 class="highlight" data-highlight-index="1">
{{ t('{0} unengaged people groups', [totalPeopleGroupsFormatted]) }}
{{ t('{0} unengaged people groups', [unengagedPeopleGroupsFormatted]) }}
</h2>
<p class="subtext">
{{ 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()
<div class="stack stack--lg | info-card__content">
<h3>{{ t('Unengaged') }}</h3>
<span>{{ t('{0} Million', ['202']) }}</span>
<span>{{ t('{0} People Groups', [totalPeopleGroupsFormatted]) }}</span>
<span>{{ t('{0} People Groups', [unengagedPeopleGroupsFormatted]) }}</span>
</div>
</div>
</div>
@ -250,7 +250,7 @@ useTextHighlight()
<div class="stack stack--xl">
<h3 class="subtext">{{ t('In partnership with the global church, our vision is for...') }}</h3>
<ul class="stack stack--md" data-list-color="primary">
<li>{{ t('Daily 24-hour prayer coverage for all {0} unengaged peoples', [totalPeopleGroupsFormatted]) }}</li>
<li>{{ t('Daily 24-hour prayer coverage for all {0} unengaged peoples', [unengagedPeopleGroupsFormatted]) }}</li>
<li>{{ t('No unengaged people groups by 2033') }}</li>
<li>{{ t('Mobilization of 20,000+ DOXA partnership missionaries') }}</li>
<li>{{ t('Fruitful engagement among frontier peoples and the under-engaged') }}</li>

View file

@ -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),