Skip to content

Commit

Permalink
Only create output files when needed. Also prefer "module" over "Modu…
Browse files Browse the repository at this point in the history
…les"
  • Loading branch information
handstandsam committed Sep 4, 2024
1 parent 76ecc73 commit 2a3a551
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ data class AggregatedCodeReferences(
val values: List<Stat.CodeReferencesStat.CodeReference>,
)

/**
* Utilities to compute aggregate stats with [StatCollector]s that can access data
* from all modules via a [InvertAllCollectedDataRepo].
*/
object CollectedStatAggregator {

private val MODULE_EXTRA_METADATA = ExtraMetadata(
key = "module_path",
key = "module",
type = ExtraDataType.STRING,
description = "Module Path"
description = "Module"
)

private fun exportFullListOfCodeReferences(
Expand Down Expand Up @@ -60,19 +64,20 @@ object CollectedStatAggregator {
}
}
}

InvertJsonReportWriter.writeJsonFile(
description = "All CodeReferences for ${statMetadata.key}",
jsonOutputFile = InvertFileUtils.outputFile(
File(reportOutputConfig.invertReportDirectory, "json"),
"code_references_${statMetadata.key}.json"
),
serializer = AggregatedCodeReferences.serializer(),
value = AggregatedCodeReferences(
metadata = statMetadata.copy(extras = statMetadata.extras.plus(MODULE_EXTRA_METADATA)),
values = allCodeReferencesForStatWithProjectPathExtra
if (allCodeReferencesForStatWithProjectPathExtra.isNotEmpty()) {
InvertJsonReportWriter.writeJsonFile(
description = "All CodeReferences for ${statMetadata.key}",
jsonOutputFile = InvertFileUtils.outputFile(
File(reportOutputConfig.invertReportDirectory, "json"),
"code_references_${statMetadata.key}.json"
),
serializer = AggregatedCodeReferences.serializer(),
value = AggregatedCodeReferences(
metadata = statMetadata.copy(extras = statMetadata.extras.plus(MODULE_EXTRA_METADATA)),
values = allCodeReferencesForStatWithProjectPathExtra
)
)
)
}
}
}

Expand Down

0 comments on commit 2a3a551

Please sign in to comment.