Skip to content

Commit

Permalink
added admin interface to rebuild bloom filter
Browse files Browse the repository at this point in the history
  • Loading branch information
tantalor committed Dec 17, 2011
1 parent f6eef4a commit 123c37a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/handlers/admin/url_sha1_bloom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from emend import Edit
from emend.model.edit import get_url_sha1_bloom

def get(handler, response):
if not handler.is_admin():
return handler.not_found(status=403)
query = Edit.all()
bloom = get_url_sha1_bloom()
bloom.reset()
count = 0
while 1:
edits = query.fetch(1000)
if not edits:
break
count += len(edits)
for edit in edits:
bloom.add(edit.url_sha1)
query = Edit.all().with_cursor(query.cursor())
bloom.put()
response.count = count
3 changes: 3 additions & 0 deletions app/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-
- /admin/url_sha1_bloom
- handlers.admin.url_sha1_bloom
-
- /iphone
- handlers.iphone
Expand Down

0 comments on commit 123c37a

Please sign in to comment.