Fixed bug causing device preset to be processed twice in some cases.

This commit is contained in:
Zaid Abdulla committed 2013-11-05 13:35:54 +03:00
1 parent 8414f463ad
commit f01f6fe477
1 file changed
+16 -14
+16 -14
View File
@@ -59,23 +59,25 @@ getPresets = (callback) ->
callback(presets, objects) callback(presets, objects)
return return
presetsCollection.find().toArray((err, p) -> if not presets
throw err if err presetsCollection.find().toArray((err, p) ->
presets = p throw err if err
presets = p
redisClient.setex('presets', config.PRESETS_CACHE_DURATION, JSON.stringify(presets)) redisClient.setex('presets', config.PRESETS_CACHE_DURATION, JSON.stringify(presets))
callback(presets, objects) if objects callback(presets, objects) if objects
) )
objectsCollection.find().toArray((err, o) -> if not objects
throw err if err objectsCollection.find().toArray((err, o) ->
objects = {} throw err if err
for i in o objects = {}
objects[i._id] = i for i in o
objects[i._id] = i
redisClient.setex('objects', config.PRESETS_CACHE_DURATION, JSON.stringify(objects)) redisClient.setex('objects', config.PRESETS_CACHE_DURATION, JSON.stringify(objects))
callback(presets, objects) if presets callback(presets, objects) if presets
) )
) )