Skip to content

Commit

Permalink
/meta optimization #1: do not fetch duplicate filehash
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianlin Shi committed Jul 29, 2016
1 parent 831e53a commit a19b5cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions server/frontend/static/coffee/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ window.client = {
,

fetchFileMeta: (filehashes, callback) ->
# ignore filehash already in meta_by_filehash.
new_filehashes = []
for filehash in filehashes
if filehash in store.metaByFilehash
continue
new_filehashes.push(filehash)
$.post('file/meta', {
filehashes: JSON.stringify(filehashes),
}, (response) ->
Expand Down
11 changes: 11 additions & 0 deletions server/frontend/static/coffee/client.js

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

2 changes: 0 additions & 2 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ def post(self):
global _userid, _filehashes
_userid = self.userid
_filehashes = filehashes
import cProfile
cProfile.run('load_meta_by_filehash(_userid, *_filehashes)')
self.write({
'meta_by_filehash': meta_by_filehash
})
Expand Down

0 comments on commit a19b5cc

Please sign in to comment.