Fixed bug causing device preset to be processed twice in some cases.
This commit is contained in:
1 parent
8414f463ad
commit
f01f6fe477
1 file changed
+16
-14
@@ -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
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user