Skip to content

Commit

Permalink
Ensure search index is ordered (#739)
Browse files Browse the repository at this point in the history
* Ensure search index is ordered

* Remove module lines lint rule

* disable attempt #2
  • Loading branch information
samuelli committed Dec 19, 2016
1 parent 32b33e5 commit 2c0681b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ load-plugins=
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
disable=missing-docstring,line-too-long,import-error,no-name-in-module,fixme,too-few-public-methods,relative-import,no-init,no-self-use,too-many-locals,too-many-arguments,too-many-branches,too-many-statements,too-many-return-statements,invalid-name
disable=missing-docstring,line-too-long,import-error,no-name-in-module,fixme,too-few-public-methods,relative-import,no-init,no-self-use,too-many-locals,too-many-arguments,too-many-branches,too-many-statements,too-many-return-statements,invalid-name,too-many-lines


[REPORTS]
Expand Down
6 changes: 4 additions & 2 deletions src/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,8 @@ def update_search_index(self, owner, repo, version_key, library, bower):
weighted.append(value)
fields.append(search.TextField(name='weighted_fields', value=' '.join(weighted)))

document = search.Document(doc_id=Library.id(owner, repo), fields=fields)
rank = int((library.updated - datetime.datetime(2016, 1, 1)).total_seconds())
document = search.Document(doc_id=Library.id(owner, repo), fields=fields, rank=rank)
index = search.Index('repo')
index.put(document)

Expand Down Expand Up @@ -816,7 +817,7 @@ def handle_get(self):

class IndexAll(RequestHandler):
def handle_get(self):
query = Library.query().order(Library.updated)
query = Library.query()
cursor = None
more = True
task_count = 0
Expand All @@ -843,6 +844,7 @@ def handle_get(self, owner, repo):

for field in document.fields:
self.response.write('%s: %s<br>' % (field.name, field.value))
self.response.write('rank: %s<br>' % (document.rank))

class UpdateAll(RequestHandler):
def handle_get(self):
Expand Down

0 comments on commit 2c0681b

Please sign in to comment.