Skip to content

Commit

Permalink
Fix to use partial indexes!
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Wisecarver committed Jul 10, 2016
1 parent 3085e1a commit 46980ed
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion share/disambiguation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ def __init__(self, id, attrs, model):
def disambiguate(self):
if not self.attrs:
return None
self.attrs.pop('description', None)
if len(self.attrs.get('title','')) > 2048:
return None
self.attrs.pop('description', None)
elif self.attrs.get('title', None):
# if the model has a title, it's an abstractcreativework
# limit the query so it uses an index
return self.model.objects.filter(**self.attrs).extra(
where=[
"octet_length(title) < 2049"
]
).first()
return self.model.objects.filter(**self.attrs).first()


Expand Down

0 comments on commit 46980ed

Please sign in to comment.