diff --git a/swh/web/misc/coverage.py b/swh/web/misc/coverage.py --- a/swh/web/misc/coverage.py +++ b/swh/web/misc/coverage.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2021 The Software Heritage developers +# Copyright (C) 2018-2022 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -17,6 +17,7 @@ from swh.scheduler.model import SchedulerMetrics from swh.web.common import archive +from swh.web.common.origin_save import get_savable_visit_types from swh.web.common.utils import get_deposits_list, reverse from swh.web.config import scheduler @@ -330,8 +331,11 @@ origins["count"] = f"{count:,}" origins["instances"] = defaultdict(dict) for instance, metrics in listers_metrics[origins_type]: - # not yet in production - if metrics.visit_type in ("bzr", "cvs"): + # these types are available in staging/docker but not yet in production + if ( + metrics.visit_type in ("bzr", "cvs") + and metrics.visit_type not in get_savable_visit_types() + ): continue instance_count = metrics.origins_known - metrics.origins_never_visited origins["instances"][instance].update( diff --git a/swh/web/tests/misc/test_coverage.py b/swh/web/tests/misc/test_coverage.py --- a/swh/web/tests/misc/test_coverage.py +++ b/swh/web/tests/misc/test_coverage.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021 The Software Heritage developers +# Copyright (C) 2021-2022 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -6,7 +6,7 @@ from datetime import datetime, timezone from itertools import chain import os -from random import choice, randint +from random import randint import uuid import pytest @@ -33,7 +33,7 @@ _get_deposits_netloc_counts.cache_clear() -def test_coverage_view_no_metrics(client): +def test_coverage_view_no_metrics(client, swh_scheduler): """ Check coverage view can be rendered when scheduler metrics and deposits data are not available. @@ -54,6 +54,7 @@ "swh.web.misc.coverage._get_nixguix_origins_count" ).return_value = 30095 listers = [] + visit_types = ["git", "hg", "svn", "bzr", "svn"] for origins in listed_origins["origins"]: # create some instances for each lister for instance in range(randint(1, 5)): @@ -64,9 +65,8 @@ # record some sample listed origins _origins = [] origin_visit_stats = [] - for i in range(randint(3, 10)): + for i, visit_type in enumerate(visit_types): url = str(uuid.uuid4()) - visit_type = choice(["git", "hg", "svn"]) _origins.append( ListedOrigin( lister_id=lister.id, @@ -124,10 +124,13 @@ assert_contains(resp, f'src="{logo_url}"') if "instances" in origins: - for visit_types in origins["instances"].values(): - for data in visit_types.values(): + for visit_types_ in origins["instances"].values(): + for data in visit_types_.values(): if data["count"]: assert_contains(resp, f'{visit_type}")