Correct the primary key of v_fax_tasks table. Coding standards require primary key to remove v_ prefix, singular form and add a _uuid postfix. Result is task_uuid has been changed to fax_task_uuid.

This commit is contained in:
markjcrane
2015-11-25 08:51:54 -07:00
parent b562c4e5ec
commit 89c2f4ecb5
6 changed files with 25 additions and 25 deletions

View File

@@ -510,7 +510,7 @@
$y = 4; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = 'v_fax_tasks';
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_uuid';
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_task_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';

View File

@@ -134,8 +134,8 @@ if(!function_exists('fax_enqueue')) {
function fax_enqueue($fax_uuid, $fax_file, $wav_file, $fax_uri, $fax_dtmf, $dial_string){
global $db, $db_type;
$task_uuid = uuid();
$dial_string .= "task_uuid='" . $task_uuid . "',";
$fax_task_uuid = uuid();
$dial_string .= "fax_task_uuid='" . $fax_task_uuid . "',";
$description = ''; //! @todo add description
if ($db_type == "pgsql") {
$date_utc_now_sql = "NOW() at time zone 'utc'";
@@ -147,7 +147,7 @@ if(!function_exists('fax_enqueue')) {
$date_utc_now_sql = "datetime('now')";
}
$sql = <<<HERE
INSERT INTO v_fax_tasks( task_uuid, fax_uuid,
INSERT INTO v_fax_tasks( fax_task_uuid, fax_uuid,
task_next_time, task_lock_time,
task_fax_file, task_wav_file, task_uri, task_dial_string, task_dtmf,
task_interrupted, task_status, task_no_answer_counter, task_no_answer_retry_counter, task_retry_counter,
@@ -160,7 +160,7 @@ VALUES (?, ?,
HERE;
$stmt = $db->prepare($sql);
$i = 0;
$stmt->bindValue(++$i, $task_uuid);
$stmt->bindValue(++$i, $fax_task_uuid);
$stmt->bindValue(++$i, $fax_uuid);
$stmt->bindValue(++$i, $fax_file);
$stmt->bindValue(++$i, $wav_file);

View File

@@ -1,7 +1,7 @@
-- @usage without queue
-- api: originate {fax_file='',wav_file='',fax_dtmf=''}user/108@domain.local &lua(fax_queue/exec.lua)
-- @usage with queue task
-- api: originate {task_uuid=''}user/108@domain.local &lua(fax_queue/exec.lua)
-- api: originate {fax_task_uuid=''}user/108@domain.local &lua(fax_queue/exec.lua)
-- @fax_dtmf
-- 0-9*# - dtmf symbols
-- @200 - dtmf duration in ms
@@ -16,12 +16,12 @@ require "resources.functions.config"
local log = require "resources.functions.log".fax_task
-- If we handle queue task
local task_uuid = session:getVariable('task_uuid')
local task if task_uuid then
local fax_task_uuid = session:getVariable('fax_task_uuid')
local task if fax_task_uuid then
local Tasks = require "fax_queue.tasks"
task = Tasks.select_task(task_uuid)
task = Tasks.select_task(fax_task_uuid)
if not task then
log.warningf("Can not found fax task: %q", tostring(task_uuid))
log.warningf("Can not found fax task: %q", tostring(fax_task_uuid))
return
end
end

View File

@@ -9,10 +9,10 @@
local Settings = require "resources.functions.lazy_settings"
local Tasks = require "fax_queue.tasks"
local task_uuid = env:getHeader('task_uuid')
local task = Tasks.select_task(task_uuid)
local fax_task_uuid = env:getHeader('fax_task_uuid')
local task = Tasks.select_task(fax_task_uuid)
if not task then
log.warningf("Can not find fax task: %q", tostring(task_uuid))
log.warningf("Can not find fax task: %q", tostring(fax_task_uuid))
return
end

View File

@@ -33,7 +33,7 @@ local Q850_TIMEOUT = {
local select_task_common_sql = [[
select
t1.task_uuid as uuid,
t1.fax_task_uuid as uuid,
t1.fax_uuid as fax_uuid,
t3.domain_name,
t3.domain_uuid,
@@ -62,11 +62,11 @@ and t2.fax_send_channels > (select count(*) from v_fax_tasks as tasks
order by t1.task_next_time
]]
local select_task_sql = select_task_common_sql .. "and t1.task_uuid='%s'"
local select_task_sql = select_task_common_sql .. "and t1.fax_task_uuid='%s'"
local aquire_task_sql = [[
update v_fax_tasks set task_status = 1, task_lock_time = ]] .. date_utc_now_sql .. [[
where task_uuid = '%s' and task_status = 0
where fax_task_uuid = '%s' and task_status = 0
]]
local wait_task_sql = [[
@@ -77,19 +77,19 @@ local wait_task_sql = [[
task_no_answer_retry_counter = %s,
task_retry_counter = %s,
task_next_time = ]] .. now_add_sec_sql .. [[
where task_uuid = '%s'
where fax_task_uuid = '%s'
]]
local remove_task_task_sql = [[
delete from v_fax_tasks
where task_uuid = '%s'
where fax_task_uuid = '%s'
]]
local release_task_sql = [[
update v_fax_tasks
set task_status = 0, task_lock_time = NULL,
task_next_time = ]] .. now_add_sec_sql .. [[
where task_uuid = '%s'
where fax_task_uuid = '%s'
]]
local release_stuck_tasks_sql = [[
@@ -131,10 +131,10 @@ local function next_task()
end
end
local function select_task(task_uuid)
local function select_task(fax_task_uuid)
local db = get_db()
local task, err = db:first_row(select_task_sql:format(task_uuid))
local task, err = db:first_row(select_task_sql:format(fax_task_uuid))
if not task then return nil, err end
task.no_answer_counter = tonumber(task.no_answer_counter)

View File

@@ -239,8 +239,8 @@ if(!function_exists('fax_enqueue')) {
function fax_enqueue($fax_uuid, $fax_file, $wav_file, $fax_uri, $fax_dtmf, $dial_string){
global $db, $db_type;
$task_uuid = uuid();
$dial_string .= "task_uuid='" . $task_uuid . "',";
$fax_task_uuid = uuid();
$dial_string .= "fax_task_uuid='" . $fax_task_uuid . "',";
$description = ''; //! @todo add description
if ($db_type == "pgsql") {
$date_utc_now_sql = "NOW() at time zone 'utc'";
@@ -252,7 +252,7 @@ if(!function_exists('fax_enqueue')) {
$date_utc_now_sql = "datetime('now')";
}
$sql = <<<HERE
INSERT INTO v_fax_tasks( task_uuid, fax_uuid,
INSERT INTO v_fax_tasks( fax_task_uuid, fax_uuid,
task_next_time, task_lock_time,
task_fax_file, task_wav_file, task_uri, task_dial_string, task_dtmf,
task_interrupted, task_status, task_no_answer_counter, task_no_answer_retry_counter, task_retry_counter,
@@ -265,7 +265,7 @@ VALUES (?, ?,
HERE;
$stmt = $db->prepare($sql);
$i = 0;
$stmt->bindValue(++$i, $task_uuid);
$stmt->bindValue(++$i, $fax_task_uuid);
$stmt->bindValue(++$i, $fax_uuid);
$stmt->bindValue(++$i, $fax_file);
$stmt->bindValue(++$i, $wav_file);