TT#62001 Limit to max 120 chars in a single line of code

Additionally update the 'require' method to lua 5.1 format

Change-Id: I7c3abbcb7c4c96cb6ad534e4030022dc49a9d28c
changes/04/31104/3
Marco Capetta 6 years ago
parent 304fcfbb7d
commit 0ee7f27ea8

@ -22,7 +22,7 @@ local NGCPAPIClient = {
__class__ = 'NGCPAPIClient'
}
require('curl')
local curl = require 'curl'
local utils = require 'ngcp.utils'
local utable = utils.table
_ENV = NGCPAPIClient
@ -83,7 +83,7 @@ function NGCPAPIClient:request(method, request)
self.c:setopt(curl.OPT_CUSTOMREQUEST, method)
self.c:setopt(curl.OPT_HTTPHEADER, headers)
local res, msg = self.c:perform()
self.c:perform()
if curl.close then
self.c:close()

@ -79,9 +79,15 @@ NGCPContractPrefs_MT.__tostring = function ()
end
local con = self.config:getDBConnection()
local query = string.format("SELECT location_id FROM provisioning.voip_contract_locations cl JOIN provisioning.voip_contract_location_blocks cb ON cb.location_id = cl.id WHERE cl.contract_id = %s AND _ipv4_net_from <= UNHEX(HEX(INET_ATON('%s'))) AND _ipv4_net_to >= UNHEX(HEX(INET_ATON('%s'))) ORDER BY cb.ip DESC, cb.mask DESC LIMIT 1", contract, ip, ip)
local query = string.format("SELECT location_id FROM provisioning.voip_contract_locations cl JOIN " ..
"provisioning.voip_contract_location_blocks cb ON cb.location_id = cl.id WHERE cl.contract_id = %s " ..
"AND _ipv4_net_from <= UNHEX(HEX(INET_ATON('%s'))) AND _ipv4_net_to >= UNHEX(HEX(INET_ATON('%s'))) " ..
"ORDER BY cb.ip DESC, cb.mask DESC LIMIT 1", contract, ip, ip)
if string.find(ip, ':') ~= nil then
query = string.format("SELECT location_id FROM provisioning.voip_contract_locations cl JOIN provisioning.voip_contract_location_blocks cb ON cb.location_id = cl.id WHERE cl.contract_id = %s AND _ipv6_net_from <= UNHEX(HEX(INET_ATON('%s'))) AND _ipv6_net_to >= UNHEX(HEX(INET_ATON('%s'))) ORDER BY cb.ip DESC, cb.mask DESC LIMIT 1", contract, ip, ip)
query = string.format("SELECT location_id FROM provisioning.voip_contract_locations cl JOIN " ..
"provisioning.voip_contract_location_blocks cb ON cb.location_id = cl.id WHERE cl.contract_id = %s " ..
"AND _ipv6_net_from <= UNHEX(HEX(INET_ATON('%s'))) AND _ipv6_net_to >= UNHEX(HEX(INET_ATON('%s'))) " ..
"ORDER BY cb.ip DESC, cb.mask DESC LIMIT 1", contract, ip, ip)
end
local cur,err = con:execute(query)
@ -104,11 +110,13 @@ NGCPContractPrefs_MT.__tostring = function ()
function NGCPContractPrefs:_load(level, contract, ip)
local con = self.config:getDBConnection()
local location_id = nil
local query = string.format("SELECT * FROM %s WHERE uuid ='%s' AND location_id IS NULL", self.db_table, contract)
local query = string.format("SELECT * FROM %s WHERE uuid ='%s' AND location_id IS NULL",
self.db_table, contract)
if ip then
location_id = self:_get_location_id(contract, ip)
if location_id then
query = string.format("SELECT * FROM %s WHERE uuid ='%s' AND location_id = %d", self.db_table, contract, location_id)
query = string.format("SELECT * FROM %s WHERE uuid ='%s' AND location_id = %d",
self.db_table, contract, location_id)
end
end
local cur = con:execute(query)

@ -133,7 +133,8 @@ end
end
local num = self.pair:lrem(callid, 1, key);
if num == 0 then
sr.log("dbg", string.format("pair:lrem[%s]=>[%s] no such key found in list, skipping decrement", callid, key));
sr.log("dbg", string.format("pair:lrem[%s]=>[%s] no such key found in list, skipping decrement",
callid, key));
return false;
end
sr.log("dbg", string.format("pair:lrem[%s]=>[%s] %d\n", callid, key, num));

@ -76,7 +76,8 @@ NGCPFaxPrefs_MT.__tostring = function ()
function NGCPFaxPrefs:_load(level, uuid)
local con = assert (self.config:getDBConnection())
local query = "SELECT fp.* FROM provisioning.voip_fax_preferences fp, provisioning.voip_subscribers s WHERE s.uuid = '" .. uuid .. "' AND fp.subscriber_id = s.id"
local query = "SELECT fp.* FROM provisioning.voip_fax_preferences fp, " ..
"provisioning.voip_subscribers s WHERE s.uuid = '" .. uuid .. "' AND fp.subscriber_id = s.id"
local cur = assert (con:execute(query))
local colnames = cur:getcolnames()
local keys = {}

@ -86,7 +86,8 @@ end
if res then
self.central:expire(key, self.config.expire)
end
sr.log("info", string.format("central:hset[%s]=>[%s] callid: %s uuid: %s start_time: %s duration: %d caller: %s callee: %s source: %s expire: %d\n",
sr.log("info", string.format("central:hset[%s]=>[%s] callid: %s uuid: %s " ..
"start_time: %s duration: %d caller: %s callee: %s source: %s expire: %d\n",
key, tostring(res),
callid, uuid,
start_time, duration,

Loading…
Cancel
Save