REPOSITORY CODING · EASY
Large energy readings shrink instead of expanding
An import measured in MWh produces a smaller energy total than the same usage in kWh. Repair the unit conversion and preserve exact decimal arithmetic across all resources.
Data EngineerFacility usage disclosure service
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
Django · 30 minute session
- Readings identify facility, id, positive integer revision, date, resource, quantity and unit. Quantities are nonnegative decimal strings with at most 12 whole digits and six fractional digits. All records, including superseded ones, must validate.
- Base units are kWh for electricity, liters for water and kilograms for waste. Electricity accepts Wh, kWh and MWh; water accepts L and m3; waste accepts g, kg and t. Normalize before summing. Round final values to three decimals, half up.
- Each (facility,id) has one current reading: the highest revision. Identical replays are harmless; conflicting copies of any one revision reject the report. Revisions can change date, resource, quantity and unit. A latest void=true record contributes nothing.
- Resolve all history before applying optional facility and month filters. A correction that moves a reading out of a month must remove it from that month. Filters never make an earlier revision current.
- Return rows by facility, month and resource, sorted lexically; each includes normalized quantity and count of active readings. Totals are by resource, sorted lexically. Preserve decimal accuracy and include zero-valued readings.
- activeReadings counts included current records. superseded is input count minus distinct current identities, including identical replays. voided counts current void records across the entire import, independent of filters.
- This is a training usage-reporting system, not a carbon accounting or regulatory compliance calculator. No emissions factors or financial values are inferred.
Python · 30 minute session
- Readings identify facility, id, positive integer revision, date, resource, quantity and unit. Quantities are nonnegative decimal strings with at most 12 whole digits and six fractional digits. All records, including superseded ones, must validate.
- Base units are kWh for electricity, liters for water and kilograms for waste. Electricity accepts Wh, kWh and MWh; water accepts L and m3; waste accepts g, kg and t. Normalize before summing. Round final values to three decimals, half up.
- Each (facility,id) has one current reading: the highest revision. Identical replays are harmless; conflicting copies of any one revision reject the report. Revisions can change date, resource, quantity and unit. A latest void=true record contributes nothing.
- Resolve all history before applying optional facility and month filters. A correction that moves a reading out of a month must remove it from that month. Filters never make an earlier revision current.