Set auto ingest timestamp when updating

This commit is contained in:
Duncan Sommerville 2015-10-21 11:18:33 -04:00
parent 0b1df6baf3
commit 6c0055895c
2 changed files with 17 additions and 1 deletions

View File

@ -30,7 +30,7 @@ class PodcastManager {
$service = new Application_Service_PodcastEpisodeService();
foreach ($autoIngestPodcasts as $podcast) {
$episodes = static::_findUningestedEpisodes($podcast, $service);
$podcast->setDbAutoIngestTimestamp(date('r'))->save();
$podcast->setDbAutoIngestTimestamp(gmdate('r'))->save();
$service->downloadEpisodes($episodes);
}

View File

@ -309,6 +309,7 @@ class Application_Service_PodcastService
self::removePrivateFields($data["podcast"]);
self::validatePodcastMetadata($data["podcast"]);
self::_updateAutoIngestTimestamp($podcast, $data);
$podcast->fromArray($data["podcast"], BasePeer::TYPE_FIELDNAME);
$podcast->save();
@ -316,6 +317,21 @@ class Application_Service_PodcastService
return $podcast->toArray(BasePeer::TYPE_FIELDNAME);
}
/**
* Update the automatic ingestion timestamp for the given Podcast
*
* @param Podcast $podcast Podcast object to update
* @param array $data Podcast update data array
*/
private static function _updateAutoIngestTimestamp($podcast, $data) {
// Get podcast data with lazy loaded columns since we can't directly call getDbAutoIngest()
$currData = $podcast->toArray(BasePeer::TYPE_FIELDNAME, true);
// Add an auto-ingest timestamp when turning auto-ingest on
if ($data["podcast"]["auto_ingest"] == 1 && $currData["auto_ingest"] != 1) {
$data["podcast"]["auto_ingest_timestamp"] = gmdate('r');
}
}
private static function removePrivateFields(&$data)
{
foreach (self::$privateFields as $key) {