Skip to content

Commit

Permalink
Remove a bunch of not used legacy endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Sep 16, 2024
1 parent 8222851 commit 207118e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 134 deletions.
134 changes: 1 addition & 133 deletions repologyapp/views/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import flask

from repologyapp.db import get_db
from repologyapp.globals import repometadata
from repologyapp.view_registry import Response, ViewRegistrar

Expand Down Expand Up @@ -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/<bound>/')
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/<name>')
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/<bound>/')
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/<bound>/')
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/<repo>/')
@ViewRegistrar('/api/v1/metapackages/in-repo/<repo>/<bound>/')
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/<repo>/')
@ViewRegistrar('/api/v1/metapackages/outdated-in-repo/<repo>/<bound>/')
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/<repo>/')
@ViewRegistrar('/api/v1/metapackages/not-in-repo/<repo>/<bound>/')
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/<repo>/')
@ViewRegistrar('/api/v1/metapackages/candidates-in-repo/<repo>/<bound>/')
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/<repo>/')
@ViewRegistrar('/api/v1/metapackages/unique-in-repo/<repo>/<bound>/')
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/<maintainer>/')
@ViewRegistrar('/api/v1/metapackages/by-maintainer/<maintainer>/<bound>/')
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/<maintainer>/')
@ViewRegistrar('/api/v1/metapackages/outdated-by-maintainer/<maintainer>/<bound>/')
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/<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/<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/<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/<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/<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/<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/<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/<repo>/<name>.svg')
def badge_version_only_for_repo(repo: str, name: str) -> Response:
return flask.redirect(
Expand All @@ -307,38 +207,6 @@ def badge_version_only_for_repo(repo: str, name: str) -> Response:
)


@ViewRegistrar('/maintainer/<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:
Expand Down
1 change: 0 additions & 1 deletion tests/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')


Expand Down

0 comments on commit 207118e

Please sign in to comment.