fix: error, when rings are empty
This commit is contained in:
+9
-3
@@ -210,7 +210,7 @@ CreateApi(function ($api) {
|
|||||||
// return only changes
|
// return only changes
|
||||||
$content = json_decode($results[0]['content'], true);
|
$content = json_decode($results[0]['content'], true);
|
||||||
$has_full_rings = true;
|
$has_full_rings = true;
|
||||||
foreach ($content as $idx => $item) {
|
foreach ($content as $_idx => $item) {
|
||||||
if (!isset($item['t-begin']) || !isset($item['t-end'])) {
|
if (!isset($item['t-begin']) || !isset($item['t-end'])) {
|
||||||
$has_full_rings = false;
|
$has_full_rings = false;
|
||||||
// optionally record $idx
|
// optionally record $idx
|
||||||
@@ -225,7 +225,10 @@ CreateApi(function ($api) {
|
|||||||
// without rings
|
// without rings
|
||||||
$results = FastDBReq($db, "SELECT * FROM RINGS WHERE classId = ?", [$classId]);
|
$results = FastDBReq($db, "SELECT * FROM RINGS WHERE classId = ?", [$classId]);
|
||||||
$rings = json_decode(findClosestDateSort($results, $day)['content'], true);
|
$rings = json_decode(findClosestDateSort($results, $day)['content'], true);
|
||||||
$out = joinArraysByKey($content, $rings, true);
|
$out = $content;
|
||||||
|
if ($rings !== null) {
|
||||||
|
$out = joinArraysByKey($content, $rings, true);
|
||||||
|
}
|
||||||
$db = null;
|
$db = null;
|
||||||
return ['data' => $out, 'type' => 1];
|
return ['data' => $out, 'type' => 1];
|
||||||
}
|
}
|
||||||
@@ -238,7 +241,10 @@ CreateApi(function ($api) {
|
|||||||
$schedule = json_decode(findClosestDateSort($results, $day)['content'], true);
|
$schedule = json_decode(findClosestDateSort($results, $day)['content'], true);
|
||||||
$results = FastDBReq($db, "SELECT * FROM RINGS WHERE classId = ?", [$classId]);
|
$results = FastDBReq($db, "SELECT * FROM RINGS WHERE classId = ?", [$classId]);
|
||||||
$rings = json_decode(findClosestDateSort($results, $day)['content'], true);
|
$rings = json_decode(findClosestDateSort($results, $day)['content'], true);
|
||||||
$out = joinArraysByKey($schedule, $rings);
|
$out = $schedule;
|
||||||
|
if ($rings !== null) {
|
||||||
|
$out = joinArraysByKey($schedule, $rings);
|
||||||
|
}
|
||||||
$db = null;
|
$db = null;
|
||||||
return ['data' => $out, 'type' => 0];
|
return ['data' => $out, 'type' => 0];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user