pub async fn import_results(
pool: &PgPool,
actor: &Actor,
revision_id: Uuid,
rows: Vec<ResultInput>,
replace: bool,
) -> AppResult<ImportSummary>Expand description
Writes a set of result values in one transaction: values with the same
name and load case are updated, new ones appended. With replace, the
values that are not in the set are removed (the set becomes the result
table – what a solver script wants).
§Invariants
- Permission: as
add_result. - Locks: the simulation revision (
FOR UPDATE); the existing values are read under that lock, so a value added concurrently is updated, not inserted twice. - Data: rows are validated first; a name and load case listed twice, or more than 2000 values (in the set or in the result table afterwards), is a 400 and nothing is written.
- Audit: one
simulation.result.importfor the whole set. - Notifications: none.
- Webhooks: one
simulation.result_added, only when a value was added or updated. - Atomic: one transaction.