SyncRule: add various helper methods

This commit is contained in:
Thomas Gelf 2016-06-23 23:14:12 +02:00
parent 7bb55fadbd
commit 516c519af9

View File

@ -50,6 +50,40 @@ class SyncRule extends DbObject
));
}
public function getLastSyncTimestamp()
{
if (! $this->hasBeenLoadedFromDb()) {
return null;
}
$db = $this->getDb();
$query = $db->select()->from(
array('sr' => 'sync_run'),
'sr.start_time'
)->where('sr.rule_id = ?', $this->id)
->order('sr.start_time DESC')
->limit(1);
return $db->fetchOne($query);
}
public function getLastSyncRunId()
{
if (! $this->hasBeenLoadedFromDb()) {
return null;
}
$db = $this->getDb();
$query = $db->select()->from(
array('sr' => 'sync_run'),
'sr.id'
)->where('sr.rule_id = ?', $this->id)
->order('sr.start_time DESC')
->limit(1);
return $db->fetchOne($query);
}
public function getPriorityForNextProperty()
{
if (! $this->hasBeenLoadedFromDb()) {
@ -115,6 +149,11 @@ class SyncRule extends DbObject
return $this->checkForChanges(true);
}
public function getCurrentSyncRunId()
{
return $this->currentSyncRunId;
}
protected function sync()
{
if ($this->sync === null) {