Updated SQL queries to include instance descriptions for API calls

This commit is contained in:
Duncan Sommerville 2014-09-19 13:00:44 -04:00
parent 62c50234ab
commit 2630d88a03
1 changed files with 55 additions and 47 deletions

View File

@ -884,6 +884,7 @@ SELECT si1.starts AS starts,
show.linked AS linked, show.linked AS linked,
si1.file_id AS file_id, si1.file_id AS file_id,
si1.id AS instance_id, si1.id AS instance_id,
si1.description AS instance_description,
si1.created AS created, si1.created AS created,
si1.last_scheduled AS last_scheduled, si1.last_scheduled AS last_scheduled,
si1.time_filled AS time_filled, si1.time_filled AS time_filled,
@ -1081,6 +1082,7 @@ SELECT si.starts AS start_timestamp,
s.description, s.description,
s.id, s.id,
si.id AS instance_id, si.id AS instance_id,
si.description AS instance_description,
si.record, si.record,
s.url, s.url,
s.image_path, s.image_path,
@ -1134,6 +1136,7 @@ SELECT si.starts AS start_timestamp,
s.description, s.description,
s.id, s.id,
si.id AS instance_id, si.id AS instance_id,
si.description AS instance_description,
si.record, si.record,
s.url, s.url,
s.image_path, s.image_path,
@ -1178,36 +1181,38 @@ SQL;
{ {
if ($i-1 >= 0) { if ($i-1 >= 0) {
$results['previousShow'][0] = array( $results['previousShow'][0] = array(
"id" => $rows[$i-1]['id'], "id" => $rows[$i-1]['id'],
"instance_id" => $rows[$i-1]['instance_id'], "instance_id" => $rows[$i-1]['instance_id'],
"name" => $rows[$i-1]['name'], "instance_description" => $rows[$i-1]['instance_description'],
"description" => $rows[$i-1]['description'], "name" => $rows[$i-1]['name'],
"url" => $rows[$i-1]['url'], "description" => $rows[$i-1]['description'],
"start_timestamp" => $rows[$i-1]['start_timestamp'], "url" => $rows[$i-1]['url'],
"end_timestamp" => $rows[$i-1]['end_timestamp'], "start_timestamp" => $rows[$i-1]['start_timestamp'],
"starts" => $rows[$i-1]['starts'], "end_timestamp" => $rows[$i-1]['end_timestamp'],
"ends" => $rows[$i-1]['ends'], "starts" => $rows[$i-1]['starts'],
"record" => $rows[$i-1]['record'], "ends" => $rows[$i-1]['ends'],
"image_path" => $rows[$i-1]['image_path'], "record" => $rows[$i-1]['record'],
"type" => "show"); "image_path" => $rows[$i-1]['image_path'],
"type" => "show");
} }
$results['currentShow'][0] = $rows[$i]; $results['currentShow'][0] = $rows[$i];
if (isset($rows[$i+1])) { if (isset($rows[$i+1])) {
$results['nextShow'][0] = array( $results['nextShow'][0] = array(
"id" => $rows[$i+1]['id'], "id" => $rows[$i+1]['id'],
"instance_id" => $rows[$i+1]['instance_id'], "instance_id" => $rows[$i+1]['instance_id'],
"name" => $rows[$i+1]['name'], "instance_description" => $rows[$i+1]['instance_description'],
"description" => $rows[$i+1]['description'], "name" => $rows[$i+1]['name'],
"url" => $rows[$i+1]['url'], "description" => $rows[$i+1]['description'],
"start_timestamp" => $rows[$i+1]['start_timestamp'], "url" => $rows[$i+1]['url'],
"end_timestamp" => $rows[$i+1]['end_timestamp'], "start_timestamp" => $rows[$i+1]['start_timestamp'],
"starts" => $rows[$i+1]['starts'], "end_timestamp" => $rows[$i+1]['end_timestamp'],
"ends" => $rows[$i+1]['ends'], "starts" => $rows[$i+1]['starts'],
"record" => $rows[$i+1]['record'], "ends" => $rows[$i+1]['ends'],
"image_path" => $rows[$i+1]['image_path'], "record" => $rows[$i+1]['record'],
"type" => "show"); "image_path" => $rows[$i+1]['image_path'],
"type" => "show");
} }
break; break;
} }
@ -1218,18 +1223,19 @@ SQL;
//if we hit this we know we've gone to far and can stop looping. //if we hit this we know we've gone to far and can stop looping.
if ($showStartTime > $utcNow) { if ($showStartTime > $utcNow) {
$results['nextShow'][0] = array( $results['nextShow'][0] = array(
"id" => $rows[$i]['id'], "id" => $rows[$i]['id'],
"instance_id" => $rows[$i]['instance_id'], "instance_id" => $rows[$i]['instance_id'],
"name" => $rows[$i]['name'], "instance_description" => $rows[$i]['instance_description'],
"description" => $rows[$i]['description'], "name" => $rows[$i]['name'],
"url" => $rows[$i]['url'], "description" => $rows[$i]['description'],
"start_timestamp" => $rows[$i]['start_timestamp'], "url" => $rows[$i]['url'],
"end_timestamp" => $rows[$i]['end_timestamp'], "start_timestamp" => $rows[$i]['start_timestamp'],
"starts" => $rows[$i]['starts'], "end_timestamp" => $rows[$i]['end_timestamp'],
"ends" => $rows[$i]['ends'], "starts" => $rows[$i]['starts'],
"record" => $rows[$i]['record'], "ends" => $rows[$i]['ends'],
"image_path" => $rows[$i]['image_path'], "record" => $rows[$i]['record'],
"type" => "show"); "image_path" => $rows[$i]['image_path'],
"type" => "show");
break; break;
} }
} }
@ -1237,17 +1243,18 @@ SQL;
//found a previous show so use it. //found a previous show so use it.
if (count($results['previousShow']) == 0 && isset($previousShowIndex)) { if (count($results['previousShow']) == 0 && isset($previousShowIndex)) {
$results['previousShow'][0] = array( $results['previousShow'][0] = array(
"id" => $rows[$previousShowIndex]['id'], "id" => $rows[$previousShowIndex]['id'],
"instance_id" => $rows[$previousShowIndex]['instance_id'], "instance_id" => $rows[$previousShowIndex]['instance_id'],
"name" => $rows[$previousShowIndex]['name'], "instance_description" => $rows[$previousShowIndex]['instance_description'],
"description" => $rows[$previousShowIndex]['description'], "name" => $rows[$previousShowIndex]['name'],
"start_timestamp" => $rows[$previousShowIndex]['start_timestamp'], "description" => $rows[$previousShowIndex]['description'],
"end_timestamp" => $rows[$previousShowIndex]['end_timestamp'], "start_timestamp" => $rows[$previousShowIndex]['start_timestamp'],
"starts" => $rows[$previousShowIndex]['starts'], "end_timestamp" => $rows[$previousShowIndex]['end_timestamp'],
"ends" => $rows[$previousShowIndex]['ends'], "starts" => $rows[$previousShowIndex]['starts'],
"record" => $rows[$previousShowIndex]['record'], "ends" => $rows[$previousShowIndex]['ends'],
"image_path" => $rows[$previousShowIndex]['image_path'], "record" => $rows[$previousShowIndex]['record'],
"type" => "show"); "image_path" => $rows[$previousShowIndex]['image_path'],
"type" => "show");
} }
return $results; return $results;
@ -1281,6 +1288,7 @@ SELECT si.starts AS start_timestamp,
s.description, s.description,
s.id, s.id,
si.id AS instance_id, si.id AS instance_id,
si.description AS instance_description,
si.record, si.record,
s.url, s.url,
s.image_path, s.image_path,