Dokumentation · Data og kilder
Master data (phase-1.md §7, §3.3; B07)
The worker turns the Customer API's list (meteringpoints) and getdetails into the metering point tree,
versioned master data and the price area. Code: elo_worker.ingest.masterdata (the appliers),
elo_worker.eloverblik (the PostgreSQL pace store, the account, the observer, the runtime),
elo_worker.jobs.eloverblik_weekly.
What is stored, and what is not
A field is stored only if it is on the allowlist (B04a's models) and its value is valid for the field.
Before anything is versioned or stored, every kept key of a record is checked, and a key whose value fails is
removed; the same cleaned record becomes the version and the body in raw.payload, for accepted and refused
items alike.
| Field | Valid when |
|---|---|
typeOfMP | a type of ref.mp_type |
subTypeOfMP, physicalStatusOfMP, netSettlementGroup, mpConnectionType, disconnectionType, settlementMethod, assetType, meterReadingOccurrence, energyTimeSeriesMeasureUnit, product | a code of its list in ref.code |
meteringPointId, parentMeteringPointId | 18 digits (and, in a getdetails body, a metering point the list registered) |
meteringGridAreaIdentification, municipalityCode | 3 digits |
gridOperatorID, balanceSupplierId | 13 digits (GLN) |
consumerCVR, dataAccessCVR | 8 digits |
postcode | 4 digits |
darReference | a UUID in the canonical form DAR writes: lower case, hyphenated (not braces, urn:uuid: or 32 bare digits, which uuid.UUID also accepts) |
the two start dates; occurrence | a date; an instant ending in Z |
mpCapacity | a plain decimal, not negative, at most three decimals |
hasRelation, isMovedOut, taxReduction, protectedName | a flag |
gridOperatorName, balanceSupplierName, cityName, streetName, meteringPointAlias | free text: letters, digits, spaces and .,-/&'()+:#, at most 100 characters (60 for city and street); no eyJ, no :// or www., no c/o; and no run of eight or more digits once everything that is not a letter or a digit is removed |
buildingNumber | a house number of DAR: 1 to 3 digits and an optional letter (5, 12B) |
floorId | a floor of DAR: st, kl, k2…k9 or 1 to 2 digits |
roomId | a door of DAR: tv, th, mf, 1 to 4 digits, or a letter and up to 3 digits |
meterNumber | up to 30 letters, digits or -, no eyJ, no run of 18 or more digits once the hyphens are removed |
The three DAR forms are case-insensitive. They are the review's (B07v-01), written from memory of DAR: no
published rule is in docs/sources/, and they are to be checked against the owner's capture; a value outside
them is dropped and counted (below), so the capture shows it.
What the checks cannot tell. The free-text bounds refuse a CPR, CVR or phone number however it is written (a
hyphen, spaces, +45), a URL and a c/o line, but no pattern tells a person's name from a company's
("Karen Testesen" from "Fjordstrøm Energi"). The lead's rulings (§7 of v1.5): gridOperatorName and
balanceSupplierName are stored, as company names from DataHub's register; meteringPointAlias is stored, the
organisation's own label for its meter, and may hold a name the organisation chose to put there. **meterNumber
is an identifier of a device, kept on purpose** to match the organisation's own meter lists; its shape cannot be
told from another number of the same length (a CVR or phone number of eight digits passes, as a meter number of
eight digits must). A DAR reference in the canonical form cannot be told from another UUID either.
locationDescription is not stored at all (the lead's ruling 1): it is text typed by people about access to
a meter and has no use in the product. The allowlist discards it (it is not counted as unknown), and
core.mp_version has no column for it (migration 0020 drops it).
The envelope of a getdetails item is checked too (success a flag, errorCode a number of at most five
digits, id an ID); errorText and stackTrace never reach the worker. An error code of more than five
digits is stored as none in raw.fetch_item.error_code and raw.fetch.error_code (a documented code has five).
Dropped values are counted, by name. Every kept value a check drops is counted in ingest.unknown_field as
<path>.<key>=<invalid> (for example result[].result.floorId=<invalid>), and a list entry that cannot be
registered (a child of a type ref.mp_type does not hold, a child that is its own root) as
result[].childMeteringPoints[]=<not registered>; a getdetails record whose own ID is not the item's is
dropped as result[].result.meteringPointId=<not the item's> and the item is a parse error. The value is never
counted or stored.
The address (streetName, buildingNumber, floorId, roomId, darReference) is
stored only when protectedName is false and no contact address says protected (N4). A protectedName that
is absent, empty or unreadable is unknown: protected_name is NULL, never false, and the address is withheld.
A protectedAddress that cannot be read counts as protected. The list carries no protection flag, so an
address never comes from the list.
The tree, versions, price area
- The tree comes from the list. A listed root is its own root; its
childMeteringPointsget the root as parent and root and their type from the child entry. Each list updateslast_seen_at,has_relation,is_moved_out, the type and the parent. A list observed before the one that last updated a metering point (an older capture replayed after a live run) is older data: it lowersfirst_seen_atand changes nothing else, and it is not reconcilable (B07v-03). It changes no status,ingest.mp_stateor chunk: the daily run's step 1 (B09,elo_worker.ingest.daily.apply_list_reconciled, in the same transaction,docs/daily-run.md) does that from whatapply_listreturns (Applied.listed,Applied.new). A list that failed, or that held an entry without a valid ID or type, is notreconcilable: nothing may conclude from it that a metering point is no longer listed (B05v-05). - Versions. The content hash covers the version columns only. A new row is written when it differs from
the current one; the old row gets
observed_to. An observation at the same instant replaces the current row; an older one writes nothing (one rule with the tree and the price area, B07v-03). The list writes a version only for a metering point without one (its subset of fields would otherwise alternate with the details' versions); a child's list version holds only its reading occurrence. An item the models could not read (a parse error) writes no version; its cleaned body is kept inraw.payload. - Price area. Rule-1 rows of
core.mp_geofollow the details' grid area throughref.grid_area. The first row starts on 2015-01-01; a change closes the open row on the local date of the observation and opens the next. An observation older than the current version derives nothing (B07v-03). A grid area that is missing or not in the table gives a row withprice_areaNULL, and the metering point is listed bywithout_price_area(formake status) untilmake set-price-area MP=<mp_id> AREA=DK1replaces its rows with one rule-3 row from 2015-01-01, which the derivation never touches. Each change incrementsops.data_version. The command prints the metering point's type and current grid area, and names its children that have no price area (they keep their own rows); it refuses an area thatref.grid_areacontradicts for the current grid area unlessFORCE=1.make unset-price-area MP=<mp_id>removes the rule-3 row, so that the next weekly run derives the price area from the grid area again. - Unknown fields are counted per response in
ingest.unknown_fieldby their path: the object they sit in, then the key if it has the shape of the API's field names (lowerCamelCase, at most 64 characters), else<key>, so that a key which is itself a value (a name, a number) is never stored.
The worker's runtime
When ELOVERBLIK_REFRESH_TOKEN is set, the worker builds the runtime at start: it records the account with the
fingerprint and generation of the configured token (step 0, the worker's side: a different token raises
credential_generation and makes the account active again), then tries to acquire the egress at most once a
minute from its main loop, never blocking, and starts the client once it owns it. Eloverblik jobs are refused
(and retried by the queue) while the egress is the capture tool's, the account is invalid, or the API's pause
(cooldown_until) ends more than a poll from now, so that no job waits for it inside the queue's claim. An
ELO_ACCOUNT_PARTY_KIND other than 0, 1 or 2 ends the worker at its start. A refused refresh
token marks the account invalid. On a graceful stop the worker releases the egress and writes the handoff
record. Every raw.fetch row the worker writes carries the account and the credential generation.
eloverblik-weekly asks getdetails for every metering point with status 1 or 3, children included, ten to a
request. A run in which every request failed (not a 200, or every item 20011) fails, and the queue retries it
by its ordinary rule; a run in which some failed is done and says how many (failed_requests), with the items
counted by outcome.
The pacer's row is moved by the database's functions only. The worker role may update the three persisted
waits of ingest.pacer itself; every deadline and counter moves through ingest.reserve_start,
ingest.finish_call and ingest.absorb (the handoff), which run with the owner's rights and never move one
earlier (P7, B07v-09). When transaction B fails, the completion is recorded alone before the error propagates,
and a reservation that finds a call still in flight finishes it first (B07v-04). The scheduler that queues it on Sundays at 02:00 is B09's (elo_worker.schedule).
Kilde: docs/master-data.md i løsningens
repository.