forked from zqy1/commentbox
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add prefetch script && update bundle.js
- Loading branch information
1 parent
d6d9e88
commit 251108b
Showing
4 changed files
with
46 additions
and
4 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
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,36 @@ | ||
#coding=utf-8 | ||
import sys | ||
sys.path.insert(0, '.') | ||
|
||
from app import create_app | ||
|
||
create_app() | ||
|
||
from models import Song, Artist, SEARCH_KEY, SUGGEST_KEY, search, suggest | ||
|
||
SEARCH_KEY = 'commentbox:search:{type}:{id}' | ||
SUGGEST_KEY = 'commentbox:suggest:{text}' | ||
|
||
songs = [song.name for song in Song.objects.all()] | ||
artists = [artist.name for artist in Artist.objects.all()] | ||
|
||
text_set = set() | ||
|
||
for name in songs + artists: | ||
for w in [name[:i] for i in range(1, len(name) + 1)]: | ||
text_set.add(w) | ||
|
||
# suggest预热 | ||
for text in text_set: | ||
print 'cache suggest', text | ||
suggest(text) | ||
|
||
# search预热 | ||
for song in Song.objects.all(): | ||
print 'cache search song', song.id | ||
search(song.id, 'song') | ||
|
||
for artist in Artist.objects.all(): | ||
print 'cache search artist', artist.id | ||
search(artist.id, 'artist') | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.