diff options
author | Ted Trask <ttrask01@yahoo.com> | 2015-12-28 04:38:51 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2015-12-28 04:38:51 +0000 |
commit | 6b8458d8656eb836811b09cf7606cff58b5a84be (patch) | |
tree | f1f110a8fa2d26c40196ce804a1f61aac655af0c /provisioning-model.lua | |
parent | 3ef565ea82a711a5e42d90a23f7b8bec8a1d3d94 (diff) | |
download | acf-provisioning-6b8458d8656eb836811b09cf7606cff58b5a84be.tar.bz2 acf-provisioning-6b8458d8656eb836811b09cf7606cff58b5a84be.tar.xz |
Minor cleanup for efficiency
Diffstat (limited to 'provisioning-model.lua')
-rw-r--r-- | provisioning-model.lua | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/provisioning-model.lua b/provisioning-model.lua index 8f57e9a..bb5142f 100644 --- a/provisioning-model.lua +++ b/provisioning-model.lua @@ -1212,16 +1212,16 @@ mymodule.update_group = function(self, group, action, create) if not tmp or #tmp == 0 then success = false errtxt = "Group does not exist" - end - - -- Find all devices that have this group so we can notify on a param default value change - sql = "SELECT d2t.device_id ".. - "FROM (devices_to_classes d2t JOIN provisioning_classes t USING(class_id) JOIN classes_to_param_groups t2g USING (class_id)) ".. - "WHERE t2g.group_id='"..provdb.escape(group.value.group_id.value).."'" - devices = getselectresponse(sql) - -- Make sure the current params are saved for each device - for i,d in ipairs(devices) do - if not saved_device_params[d.device_id] then get_device_params(d.device_id) end + else + -- Find all devices that have this group so we can notify on a param default value change + sql = "SELECT d2t.device_id ".. + "FROM (devices_to_classes d2t JOIN provisioning_classes t USING(class_id) JOIN classes_to_param_groups t2g USING (class_id)) ".. + "WHERE t2g.group_id='"..provdb.escape(group.value.group_id.value).."'" + devices = getselectresponse(sql) + -- Make sure the current params are saved for each device + for i,d in ipairs(devices) do + if not saved_device_params[d.device_id] then get_device_params(d.device_id) end + end end end if success then @@ -1415,16 +1415,16 @@ mymodule.update_param = function(self, param, action, create) if not tmp or #tmp == 0 then success = false errtxt = "Param does not exist" - end - - -- Find all devices that have this param so we can notify on a param default value change - sql = "SELECT d2t.device_id FROM (devices_to_classes d2t JOIN provisioning_classes t USING(class_id) JOIN classes_to_param_groups t2g USING (class_id) ".. - "JOIN provisioning_groups g USING(group_id) JOIN param_groups_to_params g2p USING(group_id))".. - "WHERE g2p.param_id='"..provdb.escape(param.value.param_id.value).."'" - devices = getselectresponse(sql) - -- Make sure the current params are saved for each device - for i,d in ipairs(devices) do - if not saved_device_params[d.device_id] then get_device_params(d.device_id) end + else + -- Find all devices that have this param so we can notify on a param default value change + sql = "SELECT d2t.device_id FROM (devices_to_classes d2t JOIN provisioning_classes t USING(class_id) JOIN classes_to_param_groups t2g USING (class_id) ".. + "JOIN provisioning_groups g USING(group_id) JOIN param_groups_to_params g2p USING(group_id))".. + "WHERE g2p.param_id='"..provdb.escape(param.value.param_id.value).."'" + devices = getselectresponse(sql) + -- Make sure the current params are saved for each device + for i,d in ipairs(devices) do + if not saved_device_params[d.device_id] then get_device_params(d.device_id) end + end end end if success then |