Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

Commit

Permalink
Stats broke
Browse files Browse the repository at this point in the history
  • Loading branch information
mkody committed Jun 22, 2018
1 parent d50b9af commit 096e93e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions backend/app/controllers/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ private function checkIncompleteZap($day) {
// Get its ending hour
$ts = $l->timestamp_end;
$tz = new DateTimeZone('America/New_York');
$d = new DateTime("@$ts");
$d = new DateTime();
$d->setTimestamp($ts);
$d->setTimezone($tz);

// If it doesn't end at 8pm (20h), data is complete
Expand All @@ -31,13 +32,12 @@ private function checkIncompleteZap($day) {
return $day;
}

private function encodeSource($obj, $json, $res) {
private function encodeSource($obj, $json, $res, $stats=false) {
if ($json->source == 'Cartoon Network') {
$obj->cn = json_encode($res);
} else if ($json->source == 'Zap2it') {
$obj->zap = $this->checkIncompleteZap(
json_encode($res)
);
if (!$stats) $res = $this->checkIncompleteZap($res);
$obj->zap = json_encode($res);
} else if ($json->source == 'TVGuide') {
$obj->tvguide = json_encode($res);
} else if ($json->source == 'Adult Swim') {
Expand Down Expand Up @@ -146,7 +146,7 @@ private function saveStats($f3, $json) {
$stats->lastupdate = time();

// Add from the correct source
$stats = $this->encodeSource($stats, $json, $res);
$stats = $this->encodeSource($stats, $json, $res, true);

// Save
$stats->save();
Expand Down

0 comments on commit 096e93e

Please sign in to comment.