comparison src/syncALONE.coffee @ 21:dbe2232af20f

changed syncALONE
author Mathias Gebbe <mgebbe@intevation.de>
date Fri, 13 Jun 2014 21:21:41 +0200
parents 9436298e6d78
children b90e6df48d2d
comparison
equal deleted inserted replaced
20:9436298e6d78 21:dbe2232af20f
22 DatabankObject.bank = db 22 DatabankObject.bank = db
23 23
24 syncFromESN = () -> 24 syncFromESN = () ->
25 console.log 'syncFromESN' 25 console.log 'syncFromESN'
26 26
27 async.waterfall [ 27 ####
28 (callback) -> 28 # Facebook
29 db.connect(config.params, callback) 29 try
30 (callback) -> 30 Usermap.scan ((user) ->
31 #### 31 if user.id.indexOf('@facebook') isnt -1
32 # Facebook 32 console.log "start sync for facebook user"
33 33 Facebook.sync(user)
34 try 34 ), (err) ->
35 Usermap.scan ((user) -> 35 catch err
36 if user.id.indexOf('@facebook') isnt -1 36 console.log 'Error!' + err
37 console.log "start sync for facebook user" 37
38 Facebook.sync(user) 38 # Twitter
39 ), (err) -> 39 try
40 catch err 40 Usermap.scan ((user) ->
41 console.log 'Error!' + err 41 if user.id.indexOf('@twitter') isnt -1
42 42 console.log "start sync for twitter user"
43 # Twitter 43 Twitter.sync(user)
44 try 44 ), (err) ->
45 Usermap.scan ((user) -> 45 catch err
46 if user.id.indexOf('@twitter') isnt -1 46 console.log 'Error!' + err
47 console.log "start sync for twitter user" 47
48 Twitter.sync(user) 48 # Google
49 ), (err) -> 49 try
50 catch err 50 Usermap.scan ((user) ->
51 console.log 'Error!' + err 51 if user.id.indexOf('@google') isnt -1
52 52 console.log "start sync for google user"
53 53 Google.sync(user)
54 # Google 54 ), (err) ->
55 try 55 catch err
56 Usermap.scan ((user) -> 56 console.log 'Error!' + err
57 if user.id.indexOf('@google') isnt -1 57 ####
58 console.log "start sync for google user"
59 Google.sync(user)
60 ), (err) ->
61 catch err
62 console.log 'Error!' + err
63 ####
64 ], (err, result) ->
65 console.log 'done'
66 58
67 return 59 return
68
69 60
70 postParser = (post, user, network, callback) -> 61 postParser = (post, user, network, callback) ->
71 parsed = "" 62 parsed = ""
72 #console.log "\n" + post.id + "\n" + user.id + user.displayName 63 #console.log "\n" + post.id + "\n" + user.id + user.displayName
73 #PROFILE_LINK PROFILE_NAME PROFILE_PIC_LINK_80x80=$3 POST_LINK POST_TIME CONTENT 64 #PROFILE_LINK PROFILE_NAME PROFILE_PIC_LINK_80x80=$3 POST_LINK POST_TIME CONTENT
131 # Do this every xx minutes 122 # Do this every xx minutes
132 console.log '\n\n\n' + "starting sync deamon" 123 console.log '\n\n\n' + "starting sync deamon"
133 interval = config.interval 124 interval = config.interval
134 if not (interval?) 125 if not (interval?)
135 interval = 15 * 60 * 1000 # 900 000 ms (15min) 126 interval = 15 * 60 * 1000 # 900 000 ms (15min)
136 setInterval syncFromESN, interval 127
137 128 async.waterfall [
138 syncFromESN() 129 (callback) ->
130 db.connect(config.params, callback)
131 ], (err, result) ->
132 setInterval syncFromESN, interval
133 syncFromESN()
139 134
140 return 135 return
141 136
142 sync() 137 sync()
143 138
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)