From 207118e369d9ffa3e73878efb8ce2506cd479955 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 16 Sep 2024 21:06:18 +0300 Subject: [PATCH] Remove a bunch of not used legacy endpoints --- repologyapp/views/legacy.py | 134 +----------------------------------- tests/test_flask.py | 1 - 2 files changed, 1 insertion(+), 134 deletions(-) diff --git a/repologyapp/views/legacy.py b/repologyapp/views/legacy.py index 37ecbab1..506af776 100644 --- a/repologyapp/views/legacy.py +++ b/repologyapp/views/legacy.py @@ -19,7 +19,6 @@ import flask -from repologyapp.db import get_db from repologyapp.globals import repometadata from repologyapp.view_registry import Response, ViewRegistrar @@ -188,111 +187,12 @@ def metapackage_report(name: str) -> Response: return flask.redirect(flask.url_for('project_report', name=name), 301) -@ViewRegistrar('/api/v1/metapackages/') -@ViewRegistrar('/api/v1/metapackages//') -def api_v1_metapackages(bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound, **_get_projects_args()), 301) - - @ViewRegistrar('/api/v1/metapackage/') def api_v1_metapackage(name: str) -> Response: return flask.redirect(flask.url_for('api_v1_project', name=name), 301) -@ViewRegistrar('/api/v1/metapackages/all/') -@ViewRegistrar('/api/v1/metapackages/all//') -def api_v1_metapackages_all(bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound), 301) - - -@ViewRegistrar('/api/v1/metapackages/unique/') -@ViewRegistrar('/api/v1/metapackages/unique//') -def api_v1_metapackages_unique(bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound, families=1), 301) - - -@ViewRegistrar('/api/v1/metapackages/in-repo//') -@ViewRegistrar('/api/v1/metapackages/in-repo///') -def api_v1_metapackages_in_repo(repo: str, bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound, inrepo=repo), 301) - - -@ViewRegistrar('/api/v1/metapackages/outdated-in-repo//') -@ViewRegistrar('/api/v1/metapackages/outdated-in-repo///') -def api_v1_metapackages_outdated_in_repo(repo: str, bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound, inrepo=repo, outdated=1), 301) - - -@ViewRegistrar('/api/v1/metapackages/not-in-repo//') -@ViewRegistrar('/api/v1/metapackages/not-in-repo///') -def api_v1_metapackages_not_in_repo(repo: str, bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound, notinrepo=repo), 301) - - -@ViewRegistrar('/api/v1/metapackages/candidates-in-repo//') -@ViewRegistrar('/api/v1/metapackages/candidates-in-repo///') -def api_v1_metapackages_candidates_in_repo(repo: str, bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound, inrepo=repo, families='5-'), 301) - - -@ViewRegistrar('/api/v1/metapackages/unique-in-repo//') -@ViewRegistrar('/api/v1/metapackages/unique-in-repo///') -def api_v1_metapackages_unique_in_repo(repo: str, bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound, inrepo=repo, families=1), 301) - - -@ViewRegistrar('/api/v1/metapackages/by-maintainer//') -@ViewRegistrar('/api/v1/metapackages/by-maintainer///') -def api_v1_metapackages_by_maintainer(maintainer: str, bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound, maintainer=maintainer), 301) - - -@ViewRegistrar('/api/v1/metapackages/outdated-by-maintainer//') -@ViewRegistrar('/api/v1/metapackages/outdated-by-maintainer///') -def api_v1_metapackages_outdated_by_maintainer(maintainer: str, bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('api_v1_projects', bound=bound, maintainer=maintainer, outdated=1), 301) - - -@ViewRegistrar('/graph/total/metapackages.svg') -def graph_total_metapackages() -> Response: - return flask.redirect(flask.url_for('graph_total_projects'), 301) - - -@ViewRegistrar('/graph/repo//metapackages_total.svg') -def graph_repo_metapackages_total(repo: str) -> Response: - return flask.redirect(flask.url_for('graph_repo_projects_total', repo=repo), 301) - - -@ViewRegistrar('/graph/repo//metapackages_newest.svg') -def graph_repo_metapackages_newest(repo: str) -> Response: - return flask.redirect(flask.url_for('graph_repo_projects_newest', repo=repo), 301) - - -@ViewRegistrar('/graph/repo//metapackages_newest_percent.svg') -def graph_repo_metapackages_newest_percent(repo: str) -> Response: - return flask.redirect(flask.url_for('graph_repo_projects_newest_percent', repo=repo), 301) - - -@ViewRegistrar('/graph/repo//metapackages_outdated.svg') -def graph_repo_metapackages_outdated(repo: str) -> Response: - return flask.redirect(flask.url_for('graph_repo_projects_outdated', repo=repo), 301) - - -@ViewRegistrar('/graph/repo//metapackages_outdated_percent.svg') -def graph_repo_metapackages_outdated_percent(repo: str) -> Response: - return flask.redirect(flask.url_for('graph_repo_projects_outdated_percent', repo=repo), 301) - - -@ViewRegistrar('/graph/repo//metapackages_unique.svg') -def graph_repo_metapackages_unique(repo: str) -> Response: - return flask.redirect(flask.url_for('graph_repo_projects_unique', repo=repo), 301) - - -@ViewRegistrar('/graph/repo//metapackages_unique_percent.svg') -def graph_repo_metapackages_unique_percent(repo: str) -> Response: - return flask.redirect(flask.url_for('graph_repo_projects_unique_percent', repo=repo), 301) - - +# active badges on smartmontools.org, lyx.org and others @ViewRegistrar('/badge/version-only-for-repo//.svg') def badge_version_only_for_repo(repo: str, name: str) -> Response: return flask.redirect( @@ -307,38 +207,6 @@ def badge_version_only_for_repo(repo: str, name: str) -> Response: ) -@ViewRegistrar('/maintainer//problems') -def maintainer_problems_legacy(maintainer: str) -> Response: - # actual problems listing is tied to repository+maintainer pair, - # so determine most active repo and redirect to it - - maintainer = maintainer.lower() - - maintainer_info = get_db().get_maintainer_information(maintainer) - - if not maintainer_info or not maintainer_info['num_projects_newest_per_repo']: - return (flask.render_template('maintainer/404.html', maintainer=maintainer), 404) - - bestrepo = max( - ( - maintainer_info['num_projects_newest_per_repo'][repo], - -maintainer_info['num_projects_outdated_per_repo'][repo], - repometadata[repo]['num_metapackages_newest'], - repo - ) - for repo in maintainer_info['num_projects_newest_per_repo'].keys() - )[-1] - - return flask.redirect( - flask.url_for( - 'maintainer_problems', - repo=bestrepo, - maintainer=maintainer - ), - 301 - ) - - @ViewRegistrar('/addrepo') @ViewRegistrar('/docs/addrepo') def addrepo() -> Response: diff --git a/tests/test_flask.py b/tests/test_flask.py index eb78e793..2f12c783 100755 --- a/tests/test_flask.py +++ b/tests/test_flask.py @@ -258,7 +258,6 @@ def test_maintainer(): @requires_database def test_maintainer_problems(): - checkurl_301('/maintainer/amdmi3@freebsd.org/problems') # legacy checkurl_html('/maintainer/amdmi3@freebsd.org/problems-for-repo/freebsd')