Skip to content

Verified GitHub stats #16532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions tests/unit/packaging/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,8 @@ def test_acl(self, db_session):
)

@pytest.mark.parametrize(
("home_page", "expected"),
("url", "expected"),
[
(None, None),
(
"https://github.com/pypi/warehouse",
"https://api.github.com/repos/pypi/warehouse",
Expand Down Expand Up @@ -819,14 +818,21 @@ def test_acl(self, db_session):
("[email protected]:definex/dsgnutils.git", None),
],
)
def test_github_repo_info_url(self, db_session, home_page, expected):
release = DBReleaseFactory.create(home_page=home_page)
assert release.github_repo_info_url == expected
def test_verified_github_repo_info_url(self, db_session, url, expected):
release = DBReleaseFactory.create()
release.project_urls["Homepage"] = {"url": url, "verified": True}
assert release.verified_github_repo_info_url == expected

def test_verified_github_repo_info_url_is_none_without_verified_url(
self,
db_session,
):
release = DBReleaseFactory.create()
assert release.verified_github_repo_info_url is None

@pytest.mark.parametrize(
("home_page", "expected"),
("url", "expected"),
[
(None, None),
(
"https://github.com/pypi/warehouse",
"https://api.github.com/search/issues?q=repo:pypi/warehouse"
Expand Down Expand Up @@ -864,9 +870,17 @@ def test_github_repo_info_url(self, db_session, home_page, expected):
),
],
)
def test_github_open_issue_info_url(self, db_session, home_page, expected):
release = DBReleaseFactory.create(home_page=home_page)
assert release.github_open_issue_info_url == expected
def test_verified_github_open_issue_info_url(self, db_session, url, expected):
release = DBReleaseFactory.create()
release.project_urls["Homepage"] = {"url": url, "verified": True}
assert release.verified_github_open_issue_info_url == expected

def test_verified_github_open_issueo_info_url_is_none_without_verified_url(
self,
db_session,
):
release = DBReleaseFactory.create()
assert release.verified_github_open_issue_info_url is None

def test_trusted_published_none(self, db_session):
release = DBReleaseFactory.create()
Expand Down
58 changes: 31 additions & 27 deletions warehouse/locale/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2807,74 +2807,78 @@ msgid "Verified details"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:19
#: warehouse/templates/includes/packaging/project-data.html:67
#: warehouse/templates/includes/packaging/project-data.html:114
msgid "Project links"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:46
msgid "Maintainers"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:48
msgid "Avatar for {username} from gravatar.com"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:64
msgid "Unverified details"
#: warehouse/templates/includes/packaging/project-data.html:47
msgid "GitHub Statistics"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:82
msgid "GitHub Statistics"
#: warehouse/templates/includes/packaging/project-data.html:53
msgid "Repository"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:89
#: warehouse/templates/includes/packaging/project-data.html:60
msgid "Stars:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:97
#: warehouse/templates/includes/packaging/project-data.html:68
msgid "Forks:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:105
#: warehouse/templates/includes/packaging/project-data.html:76
msgid "Open issues:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:113
#: warehouse/templates/includes/packaging/project-data.html:84
msgid "Open PRs:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:123
#: warehouse/templates/includes/packaging/project-data.html:93
msgid "Maintainers"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:95
msgid "Avatar for {username} from gravatar.com"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:111
msgid "Unverified details"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:130
msgid "Meta"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:125
#: warehouse/templates/includes/packaging/project-data.html:135
msgid "License:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:128
#: warehouse/templates/includes/packaging/project-data.html:130
#: warehouse/templates/includes/packaging/project-data.html:142
#: warehouse/templates/includes/packaging/project-data.html:148
msgid "Author:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:133
#: warehouse/templates/includes/packaging/project-data.html:135
#: warehouse/templates/includes/packaging/project-data.html:155
#: warehouse/templates/includes/packaging/project-data.html:161
#: warehouse/templates/pages/help.html:612
msgid "Maintainer:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:140
#: warehouse/templates/includes/packaging/project-data.html:169
msgid "Tags"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:150
#: warehouse/templates/includes/packaging/project-data.html:181
msgid "Requires:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:155
#: warehouse/templates/includes/packaging/project-data.html:188
msgid "Provides-Extra:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:163
#: warehouse/templates/includes/packaging/project-data.html:198
#: warehouse/templates/pages/classifiers.html:16
#: warehouse/templates/pages/classifiers.html:21
#: warehouse/templates/pages/sitemap.html:39
Expand Down
14 changes: 7 additions & 7 deletions warehouse/packaging/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,9 @@ def urls_by_verify_status(self, verified: bool):
_urls[name] = url
return _urls

@staticmethod
def get_user_name_and_repo_name(urls):
for url in urls:
@property
def verified_user_name_and_repo_name(self):
for _, url in self.urls_by_verify_status(True).items():
try:
parsed = parse_url(url)
except LocationParseError:
Expand All @@ -722,14 +722,14 @@ def get_user_name_and_repo_name(urls):
return None, None

@property
def github_repo_info_url(self):
user_name, repo_name = self.get_user_name_and_repo_name(self.urls.values())
def verified_github_repo_info_url(self):
user_name, repo_name = self.verified_user_name_and_repo_name
if user_name and repo_name:
return f"https://api.github.com/repos/{user_name}/{repo_name}"

@property
def github_open_issue_info_url(self):
user_name, repo_name = self.get_user_name_and_repo_name(self.urls.values())
def verified_github_open_issue_info_url(self):
user_name, repo_name = self.verified_user_name_and_repo_name
if user_name and repo_name:
return (
f"https://api.github.com/search/issues?q=repo:{user_name}/{repo_name}"
Expand Down
11 changes: 3 additions & 8 deletions warehouse/static/sass/blocks/_verified.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@
<div class="verified"></div>
*/

.verified {
.verified, .unverified {
ul {
padding-top: 0;
}

li {
list-style-type: circle;
list-style-position: inside;
padding-left: 20;

a {
display: inline;
padding: 0;
}
}

Expand All @@ -39,8 +34,8 @@
}

h6 {
padding-bottom: 5;
padding-top: 15;
padding-bottom: 5px;
padding-top: 15px;
}

small {
Expand Down
Loading