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