- fixed "deleteLogData" cronjob, closed #507

- improved location update function
This commit is contained in:
Exodus4D
2017-07-17 21:14:59 +02:00
parent 5d57f30782
commit 1d81395042
3 changed files with 21 additions and 14 deletions

View File

@@ -6,7 +6,7 @@
* Time: 19:35
*/
namespace cron;
namespace Cron;
use DB;
use Model;
@@ -21,7 +21,7 @@ class CharacterUpdate {
/**
* max count of "inactive" character log data that will be checked for offline status
*/
const CHARACTERS_UPDATE_LOGS_MAX = 20;
const CHARACTERS_UPDATE_LOGS_MAX = 10;
/**
* get "inactive" time for character log data in seconds
@@ -39,7 +39,7 @@ class CharacterUpdate {
* >> php index.php "/cron/deleteLogData"
* @param \Base $f3
*/
public function deleteLogData(\Base $f3){
function deleteLogData(\Base $f3){
DB\Database::instance()->getDB('PF');
$logInactiveTime = $this->getCharacterLogInactiveTime($f3);
@@ -62,11 +62,16 @@ class CharacterUpdate {
/**
* @var $characterLog Model\CharacterLogModel
*/
// force characterLog as "updated" even if no changes were made
$characterLog->characterId->updateLog([
'markUpdated' => true,
'suppressHTTPErrors' => true
]);
if(is_object($characterLog->characterId)){
// force characterLog as "updated" even if no changes were made
$characterLog->characterId->updateLog([
'markUpdated' => true,
'suppressHTTPErrors' => true
]);
}else{
// character_log does not have a character assigned -> delete
$characterLog->erase();
}
}
}
}
@@ -76,7 +81,7 @@ class CharacterUpdate {
* >> php index.php "/cron/cleanUpCharacterData"
* @param \Base $f3
*/
public function cleanUpCharacterData(\Base $f3){
function cleanUpCharacterData(\Base $f3){
DB\Database::instance()->getDB('PF');
/**
@@ -107,7 +112,7 @@ class CharacterUpdate {
* >> php index.php "/cron/deleteAuthenticationData"
* @param \Base $f3
*/
public function deleteAuthenticationData($f3){
function deleteAuthenticationData($f3){
DB\Database::instance()->getDB('PF');
/**

View File

@@ -181,7 +181,10 @@ class CharacterLogModel extends BasicModel {
public function clearCacheData(){
// clear character "LOG" cache
// -> character data without "LOG" has not changed!
$this->characterId->clearCacheDataWithPrefix(CharacterModel::DATA_CACHE_KEY_LOG);
if($this->characterId){
// characterId relation could be deleted by cron therefore check again first...
$this->characterId->clearCacheDataWithPrefix(CharacterModel::DATA_CACHE_KEY_LOG);
}
}
/**

View File

@@ -679,7 +679,7 @@ class CharacterModel extends BasicModel {
// IDs for "systemId", "stationId and "shipTypeId" that require more data
$lookupIds = [];
if( !$characterLog = $this->getLog() ){
if( !($characterLog = $this->getLog()) ){
// create new log
$characterLog = $this->rel('characterLog');
}
@@ -748,7 +748,7 @@ class CharacterModel extends BasicModel {
}
$characterLog->setData($logData);
$characterLog->characterId = $this;
$characterLog->characterId = $this->id;
$characterLog->save();
$this->characterLog = $characterLog;
@@ -808,7 +808,6 @@ class CharacterModel extends BasicModel {
){
// delete existing log
$this->characterLog->erase();
$this->save();
}
return $this;