From 7787cbb595a6138a67fd95ff88f6e91038b68733 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Tue, 12 Nov 2024 13:36:39 +0100 Subject: [PATCH] insert all datapoints --- core/src/parsers/pyreport/chunks_serde.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/core/src/parsers/pyreport/chunks_serde.rs b/core/src/parsers/pyreport/chunks_serde.rs index 2ec60fa..af887ae 100644 --- a/core/src/parsers/pyreport/chunks_serde.rs +++ b/core/src/parsers/pyreport/chunks_serde.rs @@ -69,6 +69,7 @@ where } let mut ctx = ParseCtx::new(builder, report_json.files, report_json.sessions); + ctx.labels_index = labels_index; let mut report_lines = vec![]; @@ -92,9 +93,23 @@ where }) .collect(); - let datapoints = line - .5 - .map(|dps| dps.into_iter().map(|dp| (dp.0, dp.into())).collect()); + let datapoints: Option> = line.5.map(|dps| { + dps.into_iter() + .map(|dp| (dp.0, types::CoverageDatapoint::from(dp))) + .collect() + }); + + if let Some(datapoints) = &datapoints { + for datapoint in datapoints.values() { + for label in &datapoint.labels { + if !ctx.labels_index.contains_key(label) { + let context = ctx.db.report_builder.insert_context(label)?; + ctx.labels_index.insert(label.into(), context.id); + } + } + } + } + let mut report_line = ReportLine { line_no, coverage: line.0,