Compare commits
2 Commits
c4f36235ab
...
64b50ead9f
Author | SHA1 | Date | |
---|---|---|---|
|
64b50ead9f | ||
|
a3a87d39d2 |
@ -53,6 +53,7 @@ $router->any('/api/HA', 'GoogleHomeApi@response');
|
||||
$router->post('/api/endpoint/', 'EndpointsApi@default');
|
||||
$router->any('/api/update/', 'UpdatesApi@default');
|
||||
$router->any('/api/users/status', 'UsersApi@status');
|
||||
$router->any('/api/users/subscribe', 'UsersApi@subscribe');
|
||||
|
||||
// examples
|
||||
$router->any('/api/example', 'ExampleApi@example');
|
||||
|
@ -12,6 +12,11 @@ class CronApi extends ApiController
|
||||
$backupWorker = new DatabaseBackup();
|
||||
$backupWorker->purge(5);
|
||||
|
||||
//Old Records Cleanup
|
||||
foreach (SubDeviceManager::getAllSubDevices() as $key => $value) {
|
||||
RecordManager::setHistory($value['subdevice_id']);
|
||||
}
|
||||
|
||||
$this->response(['Value' => 'OK']);
|
||||
}
|
||||
|
||||
|
@ -34,4 +34,13 @@ class UsersApi extends ApiController{
|
||||
}
|
||||
$this->response(['value'=>'OK']);
|
||||
}
|
||||
|
||||
public function subscribe(){
|
||||
//$this->requireAuth();
|
||||
|
||||
$subscriptionToken = $this->input['token'];
|
||||
$subscriptionUserId = $this->input['user_id'];
|
||||
NotificationManager::addSubscriber($subscriptionUserId, $subscriptionToken);
|
||||
$this->response(['value'=>'OK']);
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class RecordManager{
|
||||
|
||||
public static function clean ($day) {
|
||||
if (isset($day)) {
|
||||
Db::command ('DELETE FROM records WHERE `time` < ADDDATE(NOW(), INTERVAL -? DAY);', array($day));
|
||||
Db::command ('DELETE FROM records WHERE `time` < ADDDATE(NOW(), INTERVAL ? DAY);', array($day));
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,5 +110,10 @@ class RecordManager{
|
||||
public static function cleanSubdeviceRecords ($subDeviceId) {
|
||||
Db::command ('DELETE FROM records WHERE subdevice_id = ?);', array($subDeviceId));
|
||||
}
|
||||
|
||||
public static function setHistory($subDeviceId){
|
||||
$history = SubDeviceManager::getSubDevice($subDeviceId)['history'];
|
||||
if ($history > 0) self::clean(-abs($history));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user