comparison src/google.coffee @ 22:b90e6df48d2d

eachLimit instead of each
author Mathias Gebbe <mgebbe@intevation.de>
date Mon, 16 Jun 2014 17:31:05 +0200
parents 6b3f38af3fa4
children 723eaf36902c
comparison
equal deleted inserted replaced
21:dbe2232af20f 22:b90e6df48d2d
42 user = updateuser 42 user = updateuser
43 #getUser(user) 43 #getUser(user)
44 getFriends(user,callback) 44 getFriends(user,callback)
45 ], (err, friends) -> 45 ], (err, friends) ->
46 # für jeden Freunde tue dies: hier bewusst von async.eachSeries friends, ((friend, callback) -> auf async.each gewechselt 46 # für jeden Freunde tue dies: hier bewusst von async.eachSeries friends, ((friend, callback) -> auf async.each gewechselt
47 async.each friends, ((friend, callback) -> 47 async.eachLimit friends, 10, ((friend, callback) ->
48 async.waterfall [ 48 async.waterfall [
49 (callback) -> 49 (callback) ->
50 getStream(user, friend, callback) 50 getStream(user, friend, callback)
51 (stream, callback) -> 51 (stream, callback) ->
52 return if not stream? or not stream.items? or stream.items.length is 0 52 return if not stream? or not stream.items? or stream.items.length is 0
53 async.each stream.items, ((post, cb) -> 53 async.eachLimit stream.items, 10, ((post, cb) ->
54 async.waterfall [ 54 async.waterfall [
55 (callback) -> 55 (callback) ->
56 FromESN.search {uid: post.id + "@google_to_" + me, recipientUser: me}, callback 56 FromESN.search {uid: post.id + "@google_to_" + me}, callback
57 (result, callback) -> 57 (result, callback) ->
58 return if result.length isnt 0 58 return if result.length isnt 0
59 ti = new Date().getTime() - interval 59 ti = new Date().getTime() - interval
60 ts = Date.parse(post.published) 60 ts = Date.parse(post.published)
61 if (ts >= ti) 61 if (ts >= ti)
152 users = JSON.parse(decodeURI(data)) 152 users = JSON.parse(decodeURI(data))
153 return if (users.error?) 153 return if (users.error?)
154 callback null,users 154 callback null,users
155 (users, callback) -> 155 (users, callback) ->
156 #EdgeControl.removeEdges(me,'@google') 156 #EdgeControl.removeEdges(me,'@google')
157 async.each users.items, ((user,cb) -> 157 async.eachLimit 10, users.items, ((user,cb) ->
158 if user.id? 158 if user.id?
159 friends.push(user.id) 159 friends.push(user.id)
160 #Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url) 160 #Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url)
161 #EdgeControl.addEdge(me,user.id+'@google') 161 #EdgeControl.addEdge(me,user.id+'@google')
162 cb() 162 cb()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)