Skip to main content

Module resultscan

Module resultscan 

Source
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.csv checked in with a simulation revision (at most EXCHANGE_MAX_BYTES), see parse_exchange for 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 – for pick = last – the last SCAN_MAX_BYTES of a file are looked at, see extract_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§

ResultTemplate
An extraction template of a project group (a row of result_templates).
TemplateInput
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 text htmltext extracted 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 source file:line.
extract_with_tail
extract for a file larger than SCAN_MAX_BYTES: head is its beginning, tail its end (at most SCAN_MAX_BYTES each, the tail starting at a line; empty when the head holds the whole file). A template with pick = last looks 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 = first reads the head only. A tail holding a NUL (zero padding) is ignored. For a file below twice SCAN_MAX_BYTES head and tail overlap: a value found in the overlap is labelled by its line from the end, not its line number.
glob_matches
Whether name matches pattern (* 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.json or teamcraft-results.csv.
scannable
Text files that templates may scan (by extension).