keep original message date insert
This commit is contained in:
27
inc/Feed.php
27
inc/Feed.php
@@ -93,23 +93,27 @@ class Feed extends PhpObject {
|
||||
return array_shift($asFeeds);
|
||||
}
|
||||
|
||||
public function getMessages($asActivePeriod = array()) {
|
||||
public function getMessages($asConstraints=array()) {
|
||||
$asInfo = array(
|
||||
'select' => array('id_message', 'ref_msg_id', 'type', 'latitude', 'longitude', 'site_time', 'timezone', 'unix_time'),
|
||||
'select' => array(Db::getId(self::MSG_TABLE), 'ref_msg_id', 'type', 'latitude', 'longitude', 'site_time', 'timezone', 'unix_time'),
|
||||
'from' => self::MSG_TABLE,
|
||||
'constraint'=> array(Db::getId(self::FEED_TABLE) => $this->getFeedId()),
|
||||
'constOpe' => array(Db::getId(self::FEED_TABLE) => "="),
|
||||
'join' => array(self::FEED_TABLE => Db::getId(self::FEED_TABLE)),
|
||||
'constraint'=> array(Db::getId(self::FEED_TABLE, true) => $this->getFeedId()),
|
||||
'constOpe' => array(Db::getId(self::FEED_TABLE, true) => "="),
|
||||
'orderBy' => array('site_time'=>'ASC')
|
||||
);
|
||||
|
||||
if(!empty($asActivePeriod)) {
|
||||
$asInfo['constraint']['site_time'] = $asActivePeriod;
|
||||
$asInfo['constOpe']['site_time'] = "BETWEEN";
|
||||
}
|
||||
if(!empty($asConstraints)) $asInfo = array_merge($asInfo, $asConstraints);
|
||||
|
||||
return $this->oDb->selectRows($asInfo);
|
||||
}
|
||||
|
||||
public function getLastMessageId($asConstraints=array()) {
|
||||
|
||||
$asMessages = $this->getMessages($asConstraints);
|
||||
return end($asMessages)[Db::getId(self::MSG_TABLE)];
|
||||
}
|
||||
|
||||
public function checkUpdateFeed($sProjectMode) {
|
||||
$bNewMsg = false;
|
||||
|
||||
@@ -128,7 +132,7 @@ class Feed extends PhpObject {
|
||||
private function updateFeed() {
|
||||
$bNewMsg = false;
|
||||
$asData = $this->retrieveFeed();
|
||||
$sLastUpdate = date(Db::TIMESTAMP_FORMAT);
|
||||
$sNow = date(Db::TIMESTAMP_FORMAT);
|
||||
if(!isset($asData['response']['errors']) || empty($asData['response']['errors'])) {
|
||||
$asMsgs = $asData['response']['feedMessageResponse']['messages'];
|
||||
$asFeed = $asData['response']['feedMessageResponse']['feed'];
|
||||
@@ -155,7 +159,7 @@ class Feed extends PhpObject {
|
||||
'name' => $asFeed['name'],
|
||||
'description' => $asFeed['description'],
|
||||
'status' => $asFeed['status'],
|
||||
'last_update' => $sLastUpdate
|
||||
'last_update' => $sNow
|
||||
);
|
||||
$iFeedId = $this->oDb->insertUpdateRow(self::FEED_TABLE, $asFeedInfo, array('ref_feed_id'));
|
||||
|
||||
@@ -177,6 +181,7 @@ class Feed extends PhpObject {
|
||||
|
||||
$iMsgId = $this->oDb->selectId(self::MSG_TABLE, array('ref_msg_id'=>$asMsg['ref_msg_id']));
|
||||
if(!$iMsgId) {
|
||||
$asMsg['posted_on'] = $sNow;
|
||||
$this->oDb->insertRow(self::MSG_TABLE, $asMsg);
|
||||
$bNewMsg = true;
|
||||
}
|
||||
@@ -184,7 +189,7 @@ class Feed extends PhpObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
else $this->oDb->updateRow(self::FEED_TABLE, $this->getFeedId(), array('last_update'=>$sLastUpdate));
|
||||
else $this->oDb->updateRow(self::FEED_TABLE, $this->getFeedId(), array('last_update'=>$sNow));
|
||||
|
||||
return $bNewMsg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user