-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added admin interface to rebuild bloom filter
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|