docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Implement a small aggregation utility that condenses daily energy logs into a single summary, emphasizing folding/aggregation behavior from the dependency package.
Each daily log contains:
day: string labelwattHours: array of positive numbers collected that dayalerts: array of booleans for each readingreported: boolean indicating whether the day was reported upstreamThe summary returned by the API should include:
dayCount: total number of daily logs processedtotalEnergy: sum of all watt-hours across all daysaveragePerDay: mean of per-day totals, rounded to two decimal placesmaxDayEnergy/minDayEnergy: highest and lowest per-day totalsanyAlerts: true if any alert is present across all readingsallReported: true only if every daily log was reported[{ day: "Mon", wattHours: [2.5, 3.5], alerts: [false, false], reported: true }, { day: "Tue", wattHours: [1, 1, 1], alerts: [false, false, false], reported: true }, { day: "Wed", wattHours: [4], alerts: [false], reported: true }], the summary has dayCount 3, totalEnergy 13, averagePerDay 4.33, maxDayEnergy 6, minDayEnergy 3, anyAlerts false, allReported true. @test[{ day: "Thu", wattHours: [2, 2], alerts: [false, true], reported: true }, { day: "Fri", wattHours: [5], alerts: [false], reported: false }], the summary has dayCount 2, totalEnergy 9, averagePerDay 4.50, maxDayEnergy 5, minDayEnergy 4, anyAlerts true, allReported false. @test[ { dayCount: 2, totalEnergy: 10, averagePerDay: 5.00, maxDayEnergy: 6, minDayEnergy: 4, anyAlerts: false, allReported: true }, { dayCount: 1, totalEnergy: 7, averagePerDay: 7.00, maxDayEnergy: 7, minDayEnergy: 7, anyAlerts: true, allReported: false } ] produces a merged summary with dayCount 3, totalEnergy 17, averagePerDay 5.67, maxDayEnergy 7, minDayEnergy 4, anyAlerts true, allReported false. @testexport function buildSummary(dailyLogs);
export function mergeSummaries(partials);Provides aggregation and folding utilities for lists, booleans, and numbers.