From 93101687ab9cf3247bf16a2a0d43e1f5f22fa0f5 Mon Sep 17 00:00:00 2001
From: Jan-Niclas Struewer <j.n.struewer@gmail.com>
Date: Wed, 27 Sep 2023 15:25:39 +0200
Subject: [PATCH] Added code documentation for MetricsService.kt

---
 .../dataprovider/kpi/metrics/MetricsService.kt | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/metrics/MetricsService.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/metrics/MetricsService.kt
index 53c68767..4f14f3c7 100644
--- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/metrics/MetricsService.kt
+++ b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/metrics/MetricsService.kt
@@ -26,12 +26,22 @@ class MetricsService(
     val ioScope = CoroutineScope(Dispatchers.IO)
 
 
+    /**
+     * Warning: Long running function!
+     *
+     * In this function we calculate the KPIs for the given project using information from the gitlab api.
+     * Therefore, we first create a repository and tool run object in the DB.
+     *
+     * Next, we asynchronously query the gitlab API and dedicated opencode tool APIs for further data.
+     * Based upon this data we calculate RAW KPIs.
+     *
+     * Once all API responses have been processes we create a KPI tree and store this to the DB.
+     *
+     * Lastly, we update the tool run with all tools, which provided results for the given repository,
+     * and store this to the DB.
+     */
     suspend fun handleRepositoryChange(repoId: Long) = defaultScope.launch {
 
-        // TODO: we need to create the tools in the db and link them to the tool run.
-        // This should probably be done on the initial server startup, based on some
-        // config properties, as the tools don't change dynamically.
-
         /**
          * Create initial db models.
          * If this fails we want the whole method to fail as we can't continue
-- 
GitLab