From 10e517552d6a6884281d3e5b0d3e5e4158a0b7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 17 Aug 2020 18:01:03 +0200 Subject: [PATCH] Remove contributors page Ref: ~sircmpwn/git.sr.ht#311 --- gitsrht/app.py | 2 -- gitsrht/blueprints/stats.py | 42 ----------------------------- gitsrht/templates/contributors.html | 16 ----------- gitsrht/templates/repo.html | 5 ---- 4 files changed, 65 deletions(-) delete mode 100644 gitsrht/blueprints/stats.py delete mode 100644 gitsrht/templates/contributors.html diff --git a/gitsrht/app.py b/gitsrht/app.py index afafdc3..34f52a3 100644 --- a/gitsrht/app.py +++ b/gitsrht/app.py @@ -27,7 +27,6 @@ class GitApp(ScmSrhtFlask): from gitsrht.blueprints.email import mail from gitsrht.blueprints.manage import manage from gitsrht.blueprints.repo import repo - from gitsrht.blueprints.stats import stats from srht.graphql import gql_blueprint self.register_blueprint(plumbing) @@ -35,7 +34,6 @@ class GitApp(ScmSrhtFlask): self.register_blueprint(mail) self.register_blueprint(manage) self.register_blueprint(repo) - self.register_blueprint(stats) self.register_blueprint(webhooks_notify) self.register_blueprint(gql_blueprint) diff --git a/gitsrht/blueprints/stats.py b/gitsrht/blueprints/stats.py deleted file mode 100644 index e883048..0000000 --- a/gitsrht/blueprints/stats.py +++ /dev/null @@ -1,42 +0,0 @@ -import pygit2 -from datetime import datetime, timedelta -from flask import Blueprint, render_template -from gitsrht.git import Repository as GitRepository -from gitsrht.types import User -from scmsrht.access import get_repo_or_redir -from scmsrht.stats import RepoContributions, get_contrib_chart_data - -stats = Blueprint('stats', __name__) - -def get_contributions(git_repo, tip, since): - contributions = RepoContributions(User) - - since_ts = since.timestamp() - for commit in git_repo.walk(tip.id, pygit2.GIT_SORT_TIME): - timestamp = commit.commit_time + commit.commit_time_offset - if timestamp < since_ts: - break - - user = contributions.get_or_create_user( - commit.author.email, commit.author.name) - user.add_commit(timestamp) - - return contributions - -@stats.route("///contributors") -def contributors(owner, repo): - owner, repo = get_repo_or_redir(owner, repo) - since = datetime.now() - timedelta(weeks=52) - - with GitRepository(repo.path) as git_repo: - if git_repo.is_empty: - return render_template("empty-repo.html", owner=owner, repo=repo) - - default_branch = git_repo.default_branch() - tip = git_repo.get(default_branch.target) - contributions = get_contributions(git_repo, tip, since) - chart_data = get_contrib_chart_data(contributions) - - return render_template("contributors.html", view="contributors", - owner=owner, repo=repo, chart_data=chart_data, - default_branch=default_branch) diff --git a/gitsrht/templates/contributors.html b/gitsrht/templates/contributors.html deleted file mode 100644 index 2cf1e6c..0000000 --- a/gitsrht/templates/contributors.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "repo.html" %} - -{% block title %} - - {{repo.owner.canonical_name}}/{{repo.name}} contributors - - {{cfg("sr.ht", "site-name")}} git - -{% endblock %} - -{% block head %} -{% include "partials/scmcontrib-head.html" %} -{% endblock %} - -{% block content %} -{% include "partials/scmcontrib-body.html" %} -{% endblock %} diff --git a/gitsrht/templates/repo.html b/gitsrht/templates/repo.html index c99ee11..4d93832 100644 --- a/gitsrht/templates/repo.html +++ b/gitsrht/templates/repo.html @@ -57,11 +57,6 @@ owner=repo.owner.canonical_name, repo=repo.name), "refs")}} - {% if current_user.id == repo.owner_id %}