Add 24-month dept split chart below rolling trend

Stacked bar chart (Rooms/Dry/Wet) for the previous 12 months and last
12 months side by side, with a reference line marking the boundary.
No extra API calls — data comes from the existing 36-month fetch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 13:49:15 +00:00
parent 4744e74dfa
commit 6a2990b34e
3 changed files with 69 additions and 5 deletions

View file

@ -253,6 +253,24 @@ export async function weeklyActualRoutes(fastify) {
})
}
// Monthly dept split for last 24 months (indices 1235)
// — previous 12 months followed by last 12 months
const monthly_split = []
for (let i = 12; i < 36; i++) {
const tm = trendMonths[i]
const data = trendRevRaw[i]?.data ?? []
let rooms = 0, dry = 0, wet = 0
for (const d of data) {
rooms += parseFloat(d.accom?.otb ?? 0)
dry += parseFloat(d.dry?.otb ?? 0)
wet += parseFloat(d.wet?.otb ?? 0)
}
monthly_split.push({
label: `${MONTH_LABELS[tm.month - 1]}-${String(tm.year).slice(2)}`,
rooms, dry, wet,
})
}
return {
week_ending: toDateStr(weekEndDate),
week_start: toDateStr(weekStartDate),
@ -262,6 +280,7 @@ export async function weeklyActualRoutes(fastify) {
occupancy,
month_progress,
monthly_trend,
monthly_split,
}
})
}