Skip to content

Commit 748138e

Browse files
authored
Remove 'trending projects' and 'latest releases' (#12888)
1 parent ede4fa0 commit 748138e

File tree

15 files changed

+31
-332
lines changed

15 files changed

+31
-332
lines changed

tests/unit/packaging/test_init.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@
2222
from warehouse.packaging.models import File, Project, Release, Role
2323
from warehouse.packaging.tasks import ( # sync_bigquery_release_files,
2424
compute_2fa_mandate,
25-
compute_trending,
2625
update_description_html,
2726
)
2827

2928

30-
@pytest.mark.parametrize("with_trending", [True, False])
3129
@pytest.mark.parametrize("with_bq_sync", [True, False])
3230
@pytest.mark.parametrize("with_2fa_mandate", [True, False])
33-
def test_includeme(monkeypatch, with_trending, with_bq_sync, with_2fa_mandate):
31+
def test_includeme(monkeypatch, with_bq_sync, with_2fa_mandate):
3432
storage_class = pretend.stub(
3533
create_service=pretend.call_recorder(lambda *a, **kw: pretend.stub())
3634
)
@@ -40,8 +38,6 @@ def key_factory(keystring, iterate_on=None):
4038

4139
monkeypatch.setattr(packaging, "key_factory", key_factory)
4240
settings = dict()
43-
if with_trending:
44-
settings["warehouse.trending_table"] = "foobar"
4541
if with_bq_sync:
4642
settings["warehouse.release_files_table"] = "fizzbuzz"
4743
if with_2fa_mandate:
@@ -128,12 +124,6 @@ def key_factory(keystring, iterate_on=None):
128124
# )
129125
pass
130126

131-
if with_trending:
132-
assert (
133-
pretend.call(crontab(minute=0, hour=3), compute_trending)
134-
in config.add_periodic_task.calls
135-
)
136-
137127
if with_2fa_mandate:
138128
assert (
139129
pretend.call(crontab(minute=0, hour=3), compute_2fa_mandate)

tests/unit/packaging/test_search.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def test_build_search():
3535
platform="any platform",
3636
created=datetime.datetime(1956, 1, 31),
3737
classifiers=["Alpha", "Beta"],
38-
zscore=None,
3938
)
4039
obj = Project.from_db(release)
4140

@@ -55,4 +54,3 @@ def test_build_search():
5554
assert obj["platform"] == "any platform"
5655
assert obj["created"] == datetime.datetime(1956, 1, 31)
5756
assert obj["classifiers"] == ["Alpha", "Beta"]
58-
assert obj["zscore"] is None

tests/unit/packaging/test_tasks.py

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@
1515
import pretend
1616
import pytest
1717

18-
from google.cloud.bigquery import Row, SchemaField
18+
from google.cloud.bigquery import SchemaField
1919
from wtforms import Field, Form, StringField
2020

2121
import warehouse.packaging.tasks
2222

2323
from warehouse.accounts.models import WebAuthn
24-
from warehouse.cache.origin import IOriginCache
25-
from warehouse.packaging.models import Description, Project
24+
from warehouse.packaging.models import Description
2625
from warehouse.packaging.tasks import (
2726
compute_2fa_mandate,
2827
compute_2fa_metrics,
29-
compute_trending,
3028
sync_bigquery_release_files,
3129
update_bigquery_release_files,
3230
update_description_html,
@@ -45,94 +43,6 @@
4543
)
4644

4745

48-
class TestComputeTrending:
49-
@pytest.mark.parametrize("with_purges", [True, False])
50-
def test_computes_trending(self, db_request, with_purges):
51-
projects = [
52-
ProjectFactory.create(zscore=1 if not i else None) for i in range(3)
53-
]
54-
55-
results = iter(
56-
[
57-
Row((projects[1].normalized_name, 2), {"project": 0, "zscore": 1}),
58-
Row((projects[2].normalized_name, -1), {"project": 0, "zscore": 1}),
59-
]
60-
)
61-
query = pretend.stub(result=pretend.call_recorder(lambda *a, **kw: results))
62-
bigquery = pretend.stub(query=pretend.call_recorder(lambda q: query))
63-
64-
cacher = pretend.stub(purge=pretend.call_recorder(lambda keys: None))
65-
66-
def find_service(iface=None, name=None):
67-
if iface is None and name == "gcloud.bigquery":
68-
return bigquery
69-
70-
if with_purges and issubclass(iface, IOriginCache):
71-
return cacher
72-
73-
raise LookupError
74-
75-
db_request.find_service = find_service
76-
db_request.registry.settings = {
77-
"warehouse.trending_table": "example.pypi.downloads*"
78-
}
79-
80-
compute_trending(db_request)
81-
82-
assert bigquery.query.calls == [
83-
pretend.call(
84-
""" SELECT project,
85-
IF(
86-
STDDEV(downloads) > 0,
87-
(todays_downloads - AVG(downloads))/STDDEV(downloads),
88-
NULL
89-
) as zscore
90-
FROM (
91-
SELECT project,
92-
date,
93-
downloads,
94-
FIRST_VALUE(downloads) OVER (
95-
PARTITION BY project
96-
ORDER BY DATE DESC
97-
ROWS BETWEEN UNBOUNDED PRECEDING
98-
AND UNBOUNDED FOLLOWING
99-
) as todays_downloads
100-
FROM (
101-
SELECT file.project as project,
102-
DATE(timestamp) AS date,
103-
COUNT(*) as downloads
104-
FROM `example.pypi.downloads*`
105-
WHERE _TABLE_SUFFIX BETWEEN
106-
FORMAT_DATE(
107-
"%Y%m%d",
108-
DATE_ADD(CURRENT_DATE(), INTERVAL -31 day))
109-
AND
110-
FORMAT_DATE(
111-
"%Y%m%d",
112-
DATE_ADD(CURRENT_DATE(), INTERVAL -1 day))
113-
GROUP BY file.project, date
114-
)
115-
)
116-
GROUP BY project, todays_downloads
117-
HAVING SUM(downloads) >= 5000
118-
ORDER BY zscore DESC
119-
"""
120-
)
121-
]
122-
assert query.result.calls == [pretend.call()]
123-
assert cacher.purge.calls == (
124-
[pretend.call(["trending"])] if with_purges else []
125-
)
126-
127-
results = dict(db_request.db.query(Project.name, Project.zscore).all())
128-
129-
assert results == {
130-
projects[0].name: None,
131-
projects[1].name: 2,
132-
projects[2].name: -1,
133-
}
134-
135-
13646
def test_update_description_html(monkeypatch, db_request):
13747
current_version = "24.0"
13848
previous_version = "23.0"

tests/unit/test_search.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ def test_mixed_quoted_query(self):
142142
},
143143
}
144144

145-
@pytest.mark.parametrize(
146-
"order,field", [("created", "created"), ("-zscore", "zscore")]
147-
)
145+
@pytest.mark.parametrize("order,field", [("created", "created")])
148146
def test_sort_order(self, order, field):
149147
es = Search()
150148
terms = "foo bar"

tests/unit/test_views.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,6 @@ def test_index(self, db_request):
327327
UserFactory.create()
328328

329329
assert index(db_request) == {
330-
# assert that ordering is correct
331-
"latest_releases": [release2, release1],
332-
"trending_projects": [release2],
333330
"num_projects": 1,
334331
"num_users": 3,
335332
"num_releases": 2,

warehouse/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def configure(settings=None):
176176
"GITHUB_TOKEN_SCANNING_META_API_URL",
177177
default="https://github.com/api/meta/public_keys/token_scanning",
178178
)
179-
maybe_set(settings, "warehouse.trending_table", "WAREHOUSE_TRENDING_TABLE")
180179
maybe_set(settings, "warehouse.downloads_table", "WAREHOUSE_DOWNLOADS_TABLE")
181180
maybe_set(settings, "celery.broker_url", "BROKER_URL")
182181
maybe_set(settings, "celery.result_url", "REDIS_URL")

warehouse/locale/messages.pot

Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#: warehouse/views.py:141
1+
#: warehouse/views.py:140
22
msgid ""
33
"Two-factor authentication must be enabled on your account to perform this"
44
" action."
55
msgstr ""
66

7-
#: warehouse/views.py:304
7+
#: warehouse/views.py:265
88
msgid "Locale updated"
99
msgstr ""
1010

@@ -520,7 +520,7 @@ msgstr ""
520520
#: warehouse/templates/includes/accounts/profile-callout.html:18
521521
#: warehouse/templates/includes/hash-modal.html:23
522522
#: warehouse/templates/includes/packaging/project-data.html:66
523-
#: warehouse/templates/index.html:112 warehouse/templates/index.html:116
523+
#: warehouse/templates/index.html:100 warehouse/templates/index.html:104
524524
#: warehouse/templates/manage/account.html:228
525525
#: warehouse/templates/manage/account.html:234
526526
#: warehouse/templates/manage/account/totp-provision.html:32
@@ -737,7 +737,7 @@ msgid ""
737737
"Foundation</a>."
738738
msgstr ""
739739

740-
#: warehouse/templates/base.html:93 warehouse/templates/index.html:109
740+
#: warehouse/templates/base.html:93 warehouse/templates/index.html:97
741741
msgid ""
742742
"The Python Package Index (PyPI) is a repository of software for the "
743743
"Python programming language."
@@ -796,19 +796,19 @@ msgstr ""
796796

797797
#: warehouse/templates/base.html:227 warehouse/templates/base.html:248
798798
#: warehouse/templates/error-base-with-search.html:20
799-
#: warehouse/templates/index.html:55
799+
#: warehouse/templates/index.html:43
800800
msgid "Search PyPI"
801801
msgstr ""
802802

803803
#: warehouse/templates/base.html:228 warehouse/templates/base.html:249
804804
#: warehouse/templates/error-base-with-search.html:21
805-
#: warehouse/templates/index.html:58
805+
#: warehouse/templates/index.html:46
806806
msgid "Search projects"
807807
msgstr ""
808808

809809
#: warehouse/templates/base.html:232 warehouse/templates/base.html:253
810810
#: warehouse/templates/error-base-with-search.html:24
811-
#: warehouse/templates/index.html:62
811+
#: warehouse/templates/index.html:50
812812
msgid "Search"
813813
msgstr ""
814814

@@ -971,85 +971,69 @@ msgstr ""
971971
msgid "The Python Package Index"
972972
msgstr ""
973973

974-
#: warehouse/templates/index.html:43
974+
#: warehouse/templates/index.html:31
975975
msgid "Test Python package publishing with the Test Python Package Index"
976976
msgstr ""
977977

978-
#: warehouse/templates/index.html:45
978+
#: warehouse/templates/index.html:33
979979
msgid "Develop the codebase behind PyPI with the Dev Python Package Index"
980980
msgstr ""
981981

982-
#: warehouse/templates/index.html:47
982+
#: warehouse/templates/index.html:35
983983
msgid "Find, install and publish Python packages with the Python Package Index"
984984
msgstr ""
985985

986-
#: warehouse/templates/index.html:66
986+
#: warehouse/templates/index.html:54
987987
#, python-format
988988
msgid "Or <a href=\"%(href)s\">browse projects</a>"
989989
msgstr ""
990990

991-
#: warehouse/templates/index.html:73
991+
#: warehouse/templates/index.html:61
992992
#, python-format
993993
msgid "%(num_projects_formatted)s project"
994994
msgid_plural "%(num_projects_formatted)s projects"
995995
msgstr[0] ""
996996
msgstr[1] ""
997997

998-
#: warehouse/templates/index.html:80
998+
#: warehouse/templates/index.html:68
999999
#, python-format
10001000
msgid "%(num_releases_formatted)s release"
10011001
msgid_plural "%(num_releases_formatted)s releases"
10021002
msgstr[0] ""
10031003
msgstr[1] ""
10041004

1005-
#: warehouse/templates/index.html:87
1005+
#: warehouse/templates/index.html:75
10061006
#, python-format
10071007
msgid "%(num_files_formatted)s file"
10081008
msgid_plural "%(num_files_formatted)s files"
10091009
msgstr[0] ""
10101010
msgstr[1] ""
10111011

1012-
#: warehouse/templates/index.html:94
1012+
#: warehouse/templates/index.html:82
10131013
#, python-format
10141014
msgid "%(num_users_formatted)s user"
10151015
msgid_plural "%(num_users_formatted)s users"
10161016
msgstr[0] ""
10171017
msgstr[1] ""
10181018

1019-
#: warehouse/templates/index.html:111
1019+
#: warehouse/templates/index.html:99
10201020
msgid ""
10211021
"PyPI helps you find and install software developed and shared by the "
10221022
"Python community."
10231023
msgstr ""
10241024

1025-
#: warehouse/templates/index.html:112
1025+
#: warehouse/templates/index.html:100
10261026
msgid "Learn about installing packages"
10271027
msgstr ""
10281028

1029-
#: warehouse/templates/index.html:115
1029+
#: warehouse/templates/index.html:103
10301030
msgid "Package authors use PyPI to distribute their software."
10311031
msgstr ""
10321032

1033-
#: warehouse/templates/index.html:116
1033+
#: warehouse/templates/index.html:104
10341034
msgid "Learn how to package your Python code for PyPI"
10351035
msgstr ""
10361036

1037-
#: warehouse/templates/index.html:126
1038-
msgid "Trending projects"
1039-
msgstr ""
1040-
1041-
#: warehouse/templates/index.html:127
1042-
msgid "Trending projects as downloaded by the community"
1043-
msgstr ""
1044-
1045-
#: warehouse/templates/index.html:137
1046-
msgid "New releases"
1047-
msgstr ""
1048-
1049-
#: warehouse/templates/index.html:138
1050-
msgid "Hot off the press: the newest project releases"
1051-
msgstr ""
1052-
10531037
#: warehouse/templates/accounts/login.html:17
10541038
#: warehouse/templates/accounts/recovery-code.html:17
10551039
#: warehouse/templates/accounts/register.html:17
@@ -2347,7 +2331,7 @@ msgstr ""
23472331
#: warehouse/templates/manage/project/release.html:137
23482332
#: warehouse/templates/manage/project/releases.html:178
23492333
#: warehouse/templates/manage/project/settings.html:111
2350-
#: warehouse/templates/search/results.html:199
2334+
#: warehouse/templates/search/results.html:198
23512335
msgid "Close"
23522336
msgstr ""
23532337

@@ -7789,7 +7773,7 @@ msgstr ""
77897773

77907774
#: warehouse/templates/search/results.html:18
77917775
#: warehouse/templates/search/results.html:114
7792-
#: warehouse/templates/search/results.html:212
7776+
#: warehouse/templates/search/results.html:211
77937777
msgid "Search results"
77947778
msgstr ""
77957779

@@ -7861,24 +7845,20 @@ msgstr ""
78617845
msgid "Date last updated"
78627846
msgstr ""
78637847

7864-
#: warehouse/templates/search/results.html:181
7865-
msgid "Trending"
7866-
msgstr ""
7867-
7868-
#: warehouse/templates/search/results.html:194
7848+
#: warehouse/templates/search/results.html:193
78697849
msgid "Filter"
78707850
msgstr ""
78717851

7872-
#: warehouse/templates/search/results.html:205
7852+
#: warehouse/templates/search/results.html:204
78737853
msgid "Add filter"
78747854
msgstr ""
78757855

7876-
#: warehouse/templates/search/results.html:221
7856+
#: warehouse/templates/search/results.html:220
78777857
#, python-format
78787858
msgid "There were no results for '%(term)s'"
78797859
msgstr ""
78807860

7881-
#: warehouse/templates/search/results.html:223
7861+
#: warehouse/templates/search/results.html:222
78827862
#, python-format
78837863
msgid "There were no results for '%(filters)s' filter"
78847864
msgid_plural "There were no results for '%(filters)s' filters"

0 commit comments

Comments
 (0)