or run

npx @tessl/cli init
Log in

Version

Files

docs

function-utilities.mdindex.mdlist-operations.mdmathematical-operations.mdobject-operations.mdstring-processing.md
tile.json

task.mdevals/scenario-4/

Energy Log Aggregator

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 label
  • wattHours: array of positive numbers collected that day
  • alerts: array of booleans for each reading
  • reported: boolean indicating whether the day was reported upstream

The summary returned by the API should include:

  • dayCount: total number of daily logs processed
  • totalEnergy: sum of all watt-hours across all days
  • averagePerDay: mean of per-day totals, rounded to two decimal places
  • maxDayEnergy/minDayEnergy: highest and lowest per-day totals
  • anyAlerts: true if any alert is present across all readings
  • allReported: true only if every daily log was reported

Capabilities

Summarize daily logs

  • With logs [{ 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

Flag alerts and reporting completeness

  • With logs [{ 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

Merge partial summaries

  • Combining partial summaries [ { 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. @test

Implementation

@generates

API

export function buildSummary(dailyLogs);
export function mergeSummaries(partials);

Dependencies { .dependencies }

prelude-ls { .dependency }

Provides aggregation and folding utilities for lists, booleans, and numbers.