Skip to content

Commit

Permalink
add prefetch script && update bundle.js
Browse files Browse the repository at this point in the history
  • Loading branch information
dongweiming committed Sep 28, 2016
1 parent d6d9e88 commit 251108b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
8 changes: 7 additions & 1 deletion assets/src/components/CommentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ class CommentList extends Component {
</FloatingActionButton>
</div>
}
let debugPanel;
if (__DEV__) {
debugPanel = (
<DevTools />
);
}
return (
<div>
{orderBy === 'random' ?
Expand All @@ -188,7 +194,7 @@ class CommentList extends Component {
}
</List>
</div>
<DevTools />
{debugPanel}
</div>
)
}
Expand Down
36 changes: 36 additions & 0 deletions data/push_cache.py
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')

4 changes: 2 additions & 2 deletions static/js/dist/index.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/js/dist/index.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 251108b

Please sign in to comment.