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

Change return type from features.query. #4926

Merged
merged 1 commit into from Feb 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/sentry/similarity.py
Expand Up @@ -465,22 +465,27 @@ def record(self, event):
return self.index.record_multi(items)

def query(self, group):
results = {}
key = self.__number_format.pack(group.id)

results = {}
for label in self.features.keys():
alias = self.aliases[label]
scope = ':'.join((
alias,
self.__number_format.pack(group.project_id)
self.__number_format.pack(group.project_id),
))
results[label] = map(
lambda (id, score): (

for id, score in self.index.query(scope, key):
results.setdefault(
self.__number_format.unpack(id)[0],
score,
),
self.index.query(scope, key)
)
return results
{},
)[label] = score

return sorted(
results.items(),
key=lambda (id, features): sum(features.values()),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty naive, but should work well enough until we decide what kind of default weighting makes sense.

reverse=True,
)


def serialize_text_shingle(value, separator=b''):
Expand Down