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)
return
presetsCollection.find().toArray((err, p) ->
throw err if err
presets = p
if not presets
presetsCollection.find().toArray((err, p) ->
throw err if err
presets = p
redisClient.setex('presets', config.PRESETS_CACHE_DURATION, JSON.stringify(presets))
callback(presets, objects) if objects
)
redisClient.setex('presets', config.PRESETS_CACHE_DURATION, JSON.stringify(presets))
callback(presets, objects) if objects
)
objectsCollection.find().toArray((err, o) ->
throw err if err
objects = {}
for i in o
objects[i._id] = i
if not objects
objectsCollection.find().toArray((err, o) ->
throw err if err
objects = {}
for i in o
objects[i._id] = i
redisClient.setex('objects', config.PRESETS_CACHE_DURATION, JSON.stringify(objects))
callback(presets, objects) if presets
)
redisClient.setex('objects', config.PRESETS_CACHE_DURATION, JSON.stringify(objects))
callback(presets, objects) if presets
)
)