From f617f427a9dbe3d253d0c1a4547022bd87f28c72 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 22 Nov 2024 23:04:07 +0300 Subject: [PATCH] Remove unused legacy redirect endpoints --- repologyapp/views/legacy.py | 184 ------------------------------------ 1 file changed, 184 deletions(-) diff --git a/repologyapp/views/legacy.py b/repologyapp/views/legacy.py index 0a87efcd..d27b7121 100644 --- a/repologyapp/views/legacy.py +++ b/repologyapp/views/legacy.py @@ -15,124 +15,11 @@ # You should have received a copy of the GNU General Public License # along with repology. If not, see . -from typing import Collection - import flask -from repologyapp.db import get_db -from repologyapp.globals import repometadata from repologyapp.view_registry import Response, ViewRegistrar -def _get_filtered_args(wanted_args: Collection[str]) -> dict[str, str]: - return { - key: val - for key, val in flask.request.args.to_dict().items() - if key in wanted_args - } - - -def _get_projects_args() -> dict[str, str]: - return _get_filtered_args({ - 'category', - 'families', - 'families_newest', - 'has_related', - 'inrepo', - 'maintainer', - 'newest', - 'notinrepo', - 'outdated', - 'problematic', - 'repos', - 'repos_newest', - 'search', - }) - - -# /metapackages/*: logs are poluted by spam requests from huawei cloud, recheck after banning it -@ViewRegistrar('/metapackages/all/') -@ViewRegistrar('/metapackages/all//') -def metapackages_all(bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('projects', bound=bound, search=flask.request.args.to_dict().get('search')), 301) - - -@ViewRegistrar('/metapackages/unique/') -@ViewRegistrar('/metapackages/unique//') -def metapackages_unique(bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('projects', bound=bound, families=1, search=flask.request.args.to_dict().get('search')), 301) - - -@ViewRegistrar('/metapackages/widespread/') -@ViewRegistrar('/metapackages/widespread//') -def metapackages_widespread(bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('projects', bound=bound, families='10-', search=flask.request.args.to_dict().get('search')), 301) - - -@ViewRegistrar('/metapackages/in-repo//') -@ViewRegistrar('/metapackages/in-repo///') -def metapackages_in_repo(repo: str, bound: str | None = None) -> Response: - if repo not in repometadata.active_names(): - flask.abort(404) - - return flask.redirect(flask.url_for('projects', bound=bound, inrepo=repo, search=flask.request.args.to_dict().get('search')), 301) - - -@ViewRegistrar('/metapackages/outdated-in-repo//') -@ViewRegistrar('/metapackages/outdated-in-repo///') -def metapackages_outdated_in_repo(repo: str, bound: str | None = None) -> Response: - if repo not in repometadata.active_names(): - flask.abort(404) - - return flask.redirect(flask.url_for('projects', bound=bound, inrepo=repo, outdated=1, search=flask.request.args.to_dict().get('search')), 301) - - -@ViewRegistrar('/metapackages/not-in-repo//') -@ViewRegistrar('/metapackages/not-in-repo///') -def metapackages_not_in_repo(repo: str, bound: str | None = None) -> Response: - if repo not in repometadata.active_names(): - flask.abort(404) - - return flask.redirect(flask.url_for('projects', bound=bound, notinrepo=repo, search=flask.request.args.to_dict().get('search')), 301) - - -@ViewRegistrar('/metapackages/candidates-for-repo//') -@ViewRegistrar('/metapackages/candidates-for-repo///') -def metapackages_candidates_for_repo(repo: str, bound: str | None = None) -> Response: - if repo not in repometadata.active_names(): - flask.abort(404) - - return flask.redirect(flask.url_for('projects', bound=bound, inrepo=repo, families='5-', search=flask.request.args.to_dict().get('search')), 301) - - -@ViewRegistrar('/metapackages/unique-in-repo//') -@ViewRegistrar('/metapackages/unique-in-repo///') -def metapackages_unique_in_repo(repo: str, bound: str | None = None) -> Response: - if repo not in repometadata.active_names(): - flask.abort(404) - - return flask.redirect(flask.url_for('projects', bound=bound, inrepo=repo, families=1, search=flask.request.args.to_dict().get('search')), 301) - - -# /metapackages/by-maintainer/alicef@gentoo.org/ from https://wiki.gentoo.org/ -@ViewRegistrar('/metapackages/by-maintainer//') -@ViewRegistrar('/metapackages/by-maintainer///') -def metapackages_by_maintainer(maintainer: str, bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('projects', bound=bound, maintainer=maintainer, search=flask.request.args.to_dict().get('search')), 301) - - -@ViewRegistrar('/metapackages/outdated-by-maintainer//') -@ViewRegistrar('/metapackages/outdated-by-maintainer///') -def metapackages_outdated_by_maintainer(maintainer: str, bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('projects', bound=bound, maintainer=maintainer, outdated=1, search=flask.request.args.to_dict().get('search')), 301) - - -@ViewRegistrar('/metapackages/') -@ViewRegistrar('/metapackages//') -def metapackages(bound: str | None = None) -> Response: - return flask.redirect(flask.url_for('projects', bound=bound, **_get_projects_args()), 301) - - @ViewRegistrar('/project/') @ViewRegistrar('/project//') def project(name: str) -> Response: @@ -155,31 +42,6 @@ def metapackage_packages(name: str) -> Response: return flask.redirect(flask.url_for('project_packages', name=name), 301) -@ViewRegistrar('/metapackage//information') -def metapackage_information(name: str) -> Response: - return flask.redirect(flask.url_for('project_information', name=name), 301) - - -@ViewRegistrar('/metapackage//history') -def metapackage_history(name: str) -> Response: - return flask.redirect(flask.url_for('project_history', name=name), 301) - - -@ViewRegistrar('/metapackage//related') -def metapackage_related(name: str) -> Response: - return flask.redirect(flask.url_for('project_related', name=name), 301) - - -@ViewRegistrar('/metapackage//badges') -def metapackage_badges(name: str) -> Response: - return flask.redirect(flask.url_for('project_badges', name=name), 301) - - -@ViewRegistrar('/metapackage//report', methods=['GET', 'POST']) -def metapackage_report(name: str) -> Response: - return flask.redirect(flask.url_for('project_report', name=name), 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: @@ -193,49 +55,3 @@ def badge_version_only_for_repo(repo: str, name: str) -> Response: ), 301 ) - - -# /maintainer/*/problems: logs are poluted by spam requests from huawei cloud, recheck after banning it -# XXX: don't forget to remove test and get_db import along with this -@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 - ) - - -# reposiotry template was pointing here, recheck after this is fixed -@ViewRegistrar('/addrepo') -def addrepo() -> Response: - return flask.redirect(flask.url_for('docs_requirements'), 301) - - -# internal performance testing tool accessed it, recheck after this is fixed -@ViewRegistrar('/about') -def about() -> Response: - return flask.redirect(flask.url_for('docs_about'), 301)