Expand description
Result values from small, structured files at check-in – never from big result files (those are stored, not parsed).
Two ways, both bounded and pure (no database, no I/O here):
- the exchange file
teamcraft-results.json/teamcraft-results.csvchecked in with a simulation revision (at mostEXCHANGE_MAX_BYTES), seeparse_exchangefor the schema; - extraction templates of a project group (
ResultTemplate): a file name pattern plus a regular expression (one capture group), a CSV column or a column of a whitespace table with quoted headers (Fluent report files) that finds one number in a text file; only the first and – forpick = last– the lastSCAN_MAX_BYTESof a file are looked at, seeextract_with_tail.
Regular expressions are compiled with the regex crate’s size limits and
run in time linear in the input (no backtracking), so a hostile pattern or
file can neither hang nor exhaust the server.
Structs§
- Result
Template - An extraction template of a project group (a row of
result_templates). - Template
Input - A template as entered (web form, REST API).
Enums§
- Method
- How a template finds its number.
Constants§
- EXCHANGE_
CSV - EXCHANGE_
JSON - The exchange files, by (lower case) name.
- EXCHANGE_
MAX_ BYTES - Largest exchange file; a bigger one is refused with the check-in.
- MAX_
PATTERN_ LEN - Longest regular expression of a template.
- MAX_
TEMPLATES - Templates of one project group.
- SCAN_
MAX_ BYTES - Bytes of a text file that templates look at (the beginning).
- SCAN_
MAX_ LINES - Lines (rows) looked at per file.
Functions§
- extract
- The values the templates find in one file (
bytes= its beginning; for an HTML report the texthtmltextextracted in the isolated child, with table rows as lines and cells separated by|– the server never parses HTML itself). A template that does not match yields nothing; each value carries its sourcefile:line. - extract_
with_ tail extractfor a file larger thanSCAN_MAX_BYTES:headis its beginning,tailits end (at mostSCAN_MAX_BYTESeach, the tail starting at a line; empty when the head holds the whole file). A template withpick = lastlooks at the tail first – a solver writes its final values at the end – and falls back to the head; table headers (csv,table) always come from the head.pick = firstreads the head only. A tail holding a NUL (zero padding) is ignored. For a file below twiceSCAN_MAX_BYTEShead and tail overlap: a value found in the overlap is labelled by its line from the end, not its line number.- glob_
matches - Whether
namematchespattern(*any text,?one character; no case distinction). - is_
exchange_ name - Whether a file name is one of the exchange files.
- parse_
exchange - Reads
teamcraft-results.jsonorteamcraft-results.csv. - scannable
- Text files that templates may scan (by extension).