From 535ddf93bca58c6b930177156512d02bac386a40 Mon Sep 17 00:00:00 2001
From: Martin Weise <martin.weise@tuwien.ac.at>
Date: Sat, 9 Nov 2024 19:47:25 +0000
Subject: [PATCH] Resolve "Bug prevents volume computation when data length
 column in Metadata DB is null"

---
 .docs/.swagger/api.base.yaml                             | 4 ++--
 .docs/.swagger/api.yaml                                  | 4 ++--
 .docs/changelog.md                                       | 4 +++-
 .docs/index.md                                           | 5 ++++-
 .gitlab-ci.yml                                           | 8 ++++++--
 .../src/main/java/at/tuwien/config/MetricsConfig.java    | 9 ++++++++-
 6 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/.docs/.swagger/api.base.yaml b/.docs/.swagger/api.base.yaml
index b7bd0570ee..864ee99e28 100644
--- a/.docs/.swagger/api.base.yaml
+++ b/.docs/.swagger/api.base.yaml
@@ -11,7 +11,7 @@ components:
       type: http
 externalDocs:
   description: Project Website
-  url: https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/1.4.7/
+  url: https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/1.5/
 info:
   contact:
     email: andreas.rauber@tuwien.ac.at
@@ -24,7 +24,7 @@ info:
     name: Apache 2.0
     url: https://www.apache.org/licenses/LICENSE-2.0
   title: DBRepo REST API
-  version: 1.4.7
+  version: 1.5.1
 openapi: 3.1.0
 servers:
   - description: Test Instance
diff --git a/.docs/.swagger/api.yaml b/.docs/.swagger/api.yaml
index 1857e4bb3f..714e7c1dd8 100644
--- a/.docs/.swagger/api.yaml
+++ b/.docs/.swagger/api.yaml
@@ -16,7 +16,7 @@ info:
     name: Apache 2.0
     url: 'https://www.apache.org/licenses/LICENSE-2.0'
   title: DBRepo REST API
-  version: 1.4.7
+  version: 1.5.1
 servers:
   - description: Test Instance
     url: 'https://test.dbrepo.tuwien.ac.at'
@@ -24,7 +24,7 @@ servers:
     url: 'http://localhost'
 externalDocs:
   description: Project Website
-  url: 'https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/1.4.7/'
+  url: 'https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/1.5/'
 paths:
   /api/analyse/datatypes:
     get:
diff --git a/.docs/changelog.md b/.docs/changelog.md
index 075bde6045..f2a35ee8f9 100644
--- a/.docs/changelog.md
+++ b/.docs/changelog.md
@@ -2,7 +2,7 @@
 author: Martin Weise
 ---
 
-## v1.5.1 (2024-11-07)
+## v1.5.1 (2024-11-09)
 
 [:simple-gitlab: GitLab Release](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/tags/v1.5.1)
 
@@ -10,6 +10,8 @@ author: Martin Weise
 
 #### Fixes
 
+* Bug where the data volume could not be calculated when the data length column in the Metadata Database is `null`
+  in [#462](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/462).
 * Bug where the schema could not be created manually 
   in [#461](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/461).
 
diff --git a/.docs/index.md b/.docs/index.md
index cb86ce7e69..b0a47b3c6f 100644
--- a/.docs/index.md
+++ b/.docs/index.md
@@ -46,4 +46,7 @@ Installing DBRepo is very easy or
 
 ## How can I try DBRepo?
 
-[:fontawesome-solid-flask: &nbsp;Demonstration Instance](https://test.dbrepo.tuwien.ac.at){ .md-button .md-button--primary target="_blank" }
\ No newline at end of file
+There's a hosted [demo environment](https://test.dbrepo.tuwien.ac.at) maintained 
+by [DS-IFS](https://informatics.tuwien.ac.at/orgs/e194-04) where you can explore DBRepo without installing it locally.
+
+[:fontawesome-solid-flask: &nbsp;Demo Environment](https://test.dbrepo.tuwien.ac.at){ .md-button .md-button--primary target="_blank" }
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c325d049e6..f6c11fbf88 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,8 +4,8 @@ variables:
   TESTCONTAINERS_RYUK_DISABLED: "false"
   PYTHON_VERSION: "3.11"
   DOC_VERSION: "1.5"
-  APP_VERSION: "1.5.0"
-  CHART_VERSION: "1.5.0"
+  APP_VERSION: "1.5.1"
+  CHART_VERSION: "1.5.1"
   CACHE_FALLBACK_KEY: ${CI_DEFAULT_BRANCH}
   # This will supress any download for dependencies and plugins or upload messages which would clutter the console log.
   # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
@@ -393,6 +393,10 @@ release-helm:
     refs:
       - /^release-.*/
   when: manual
+  needs:
+    - build-helm
+  dependencies:
+    - build-helm
   before_script:
     - "docker logout ${CI_REGISTRY_URL}"
     - "echo ${CI_REGISTRY_PASSWORD} | docker login --username ${CI_REGISTRY_USER} --password-stdin ${CI_REGISTRY_URL}"
diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/config/MetricsConfig.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/config/MetricsConfig.java
index 1b7578b4bc..b86a97a4dc 100644
--- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/config/MetricsConfig.java
+++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/config/MetricsConfig.java
@@ -14,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
+import java.util.Objects;
+
 @Log4j2
 @Configuration
 public class MetricsConfig {
@@ -70,7 +72,12 @@ public class MetricsConfig {
                     if (tableRepository.findAll().isEmpty()) {
                         return 0;
                     }
-                    return tableRepository.findAll().stream().map(Table::getDataLength).mapToLong(d -> d).sum();
+                    return tableRepository.findAll()
+                            .stream()
+                            .map(Table::getDataLength)
+                            .filter(Objects::nonNull)
+                            .mapToLong(d -> d)
+                            .sum();
                 })
                 .description("The total volume of available research data")
                 .strongReference(true)
-- 
GitLab