Skip to content
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

Add zscore to Project document mapping #5252

Merged
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
2 changes: 2 additions & 0 deletions tests/unit/packaging/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_build_search():
platform="any platform",
created=datetime.datetime(1956, 1, 31),
classifiers=["Alpha", "Beta"],
zscore=None,
)
obj = Project.from_db(release)

Expand All @@ -54,3 +55,4 @@ def test_build_search():
assert obj["platform"] == "any platform"
assert obj["created"] == datetime.datetime(1956, 1, 31)
assert obj["classifiers"] == ["Alpha", "Beta"]
assert obj["zscore"] is None
4 changes: 3 additions & 1 deletion warehouse/packaging/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import packaging.version

from elasticsearch_dsl import Date, Document, Keyword, Text, analyzer
from elasticsearch_dsl import Date, Document, Float, Keyword, Text, analyzer

from warehouse.search.utils import doc_type

Expand Down Expand Up @@ -49,6 +49,7 @@ class Project(Document):
platform = Keyword()
created = Date()
classifiers = Keyword(multi=True)
zscore = Float()

@classmethod
def from_db(cls, release):
Expand All @@ -71,5 +72,6 @@ def from_db(cls, release):
obj["platform"] = release.platform
obj["created"] = release.created
obj["classifiers"] = release.classifiers
obj["zscore"] = release.zscore

return obj
1 change: 1 addition & 0 deletions warehouse/search/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def _project_docs(db, project_name=None):
classifiers,
Project.normalized_name,
Project.name,
Project.zscore,
)
.select_from(releases_list)
.join(Release, Release.id == releases_list.c.id)
Expand Down