- added new map option for auto-delete expired WHs, closed #219
This commit is contained in:
@@ -20,8 +20,11 @@ halfHour = */30 * * * *
|
||||
downtime = 0 11 * * *
|
||||
|
||||
[CRON.jobs]
|
||||
; delete expired connections (e.g. EOL)
|
||||
deleteConnections = Cron\MapUpdate->deleteConnections, @fiveMinutes
|
||||
; delete EOL connections
|
||||
deleteEolConnections = Cron\MapUpdate->deleteEolConnections, @fiveMinutes
|
||||
|
||||
; delete expired wh connections
|
||||
deleteExpiredConnections = Cron\MapUpdate->deleteExpiredConnections, @hourly
|
||||
|
||||
; disable character log data
|
||||
deactivateLogData = Cron\CharacterUpdate->deactivateLogData, @instant
|
||||
|
||||
@@ -64,11 +64,11 @@ class MapUpdate {
|
||||
}
|
||||
|
||||
/**
|
||||
* delete expired connections (EOL connections)
|
||||
* >> php index.php "/cron/deleteConnections"
|
||||
* delete expired EOL connections
|
||||
* >> php index.php "/cron/deleteEolConnections"
|
||||
* @param \Base $f3
|
||||
*/
|
||||
function deleteConnections(\Base $f3){
|
||||
function deleteEolConnections(\Base $f3){
|
||||
$eolExpire = (int)$f3->get('PATHFINDER.CACHE.EXPIRE_CONNECTIONS_EOL');
|
||||
|
||||
if($eolExpire > 0){
|
||||
@@ -81,12 +81,12 @@ class MapUpdate {
|
||||
`map` ON
|
||||
`map`.`id` = `con`.`mapId`
|
||||
WHERE
|
||||
`map`.`deleteExpiredConnections` = :deleteExpiredConnections AND
|
||||
`map`.`deleteEolConnections` = :deleteEolConnections AND
|
||||
TIMESTAMPDIFF(SECOND, `con`.`eolUpdated`, NOW() ) > :expire_time
|
||||
";
|
||||
|
||||
$connectionsData = $pfDB->exec($sql, [
|
||||
'deleteExpiredConnections' => 1,
|
||||
'deleteEolConnections' => 1,
|
||||
'expire_time' => $eolExpire
|
||||
]);
|
||||
|
||||
@@ -105,6 +105,50 @@ class MapUpdate {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete expired WH connections after max lifetime for wormholes is reached
|
||||
* >> php index.php "/cron/deleteExpiredConnections"
|
||||
* @param \Base $f3
|
||||
*/
|
||||
function deleteExpiredConnections(\Base $f3){
|
||||
$whExpire = (int)$f3->get('PATHFINDER.CACHE.EXPIRE_CONNECTIONS_WH');
|
||||
|
||||
if($whExpire > 0){
|
||||
$pfDB = DB\Database::instance()->getDB('PF');
|
||||
|
||||
$sql = "SELECT
|
||||
`con`.`id`
|
||||
FROM
|
||||
`connection` `con` INNER JOIN
|
||||
`map` ON
|
||||
`map`.`id` = `con`.`mapId`
|
||||
WHERE
|
||||
`map`.`deleteExpiredConnections` = :deleteExpiredConnections AND
|
||||
`con`.`scope` = :scope AND
|
||||
TIMESTAMPDIFF(SECOND, `con`.`created`, NOW() ) > :expire_time
|
||||
";
|
||||
|
||||
$connectionsData = $pfDB->exec($sql, [
|
||||
'deleteExpiredConnections' => 1,
|
||||
'scope' => 'wh',
|
||||
'expire_time' => $whExpire
|
||||
]);
|
||||
|
||||
if($connectionsData){
|
||||
/**
|
||||
* @var $connection Model\ConnectionModel
|
||||
*/
|
||||
$connection = Model\BasicModel::getNew('ConnectionModel');
|
||||
foreach($connectionsData as $data){
|
||||
$connection->getById( (int)$data['id'] );
|
||||
if( !$connection->dry() ){
|
||||
$connection->erase();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all expired signatures on "inactive" systems
|
||||
* >> php index.php "/cron/deleteSignatures"
|
||||
|
||||
@@ -70,6 +70,11 @@ class MapModel extends BasicModel {
|
||||
'nullable' => false,
|
||||
'default' => 1
|
||||
],
|
||||
'deleteEolConnections' => [
|
||||
'type' => Schema::DT_BOOL,
|
||||
'nullable' => false,
|
||||
'default' => 1
|
||||
],
|
||||
'systems' => [
|
||||
'has-many' => ['Model\SystemModel', 'mapId']
|
||||
],
|
||||
@@ -150,6 +155,7 @@ class MapModel extends BasicModel {
|
||||
$mapData->name = $this->name;
|
||||
$mapData->icon = $this->icon;
|
||||
$mapData->deleteExpiredConnections = $this->deleteExpiredConnections;
|
||||
$mapData->deleteEolConnections = $this->deleteEolConnections;
|
||||
$mapData->created = strtotime($this->created);
|
||||
$mapData->updated = strtotime($this->updated);
|
||||
|
||||
|
||||
@@ -137,6 +137,8 @@ CONSTELLATION_SYSTEMS = 1728000
|
||||
EXPIRE_MAX = 864000
|
||||
; expire time for EOL (end of life) connections (seconds) (default: 4h + 15min)
|
||||
EXPIRE_CONNECTIONS_EOL = 15300
|
||||
; expire time for WH connections (seconds) (default: 2d)
|
||||
EXPIRE_CONNECTIONS_WH = 172800
|
||||
; expire time for signatures (inactive systems) (seconds) (default 3d)
|
||||
EXPIRE_SIGNATURES = 259200
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ define([
|
||||
dialogMapSettingsContainerId: 'pf-map-dialog-settings', // id for the "settings" container
|
||||
dialogMapDownloadContainerId: 'pf-map-dialog-download', // id for the "download" container
|
||||
|
||||
deleteExpiredConnectionsId: 'pf-map-dialog-delete-connections', // id for "deleteExpiredConnections" checkbox
|
||||
deleteExpiredConnectionsId: 'pf-map-dialog-delete-connections-expired', // id for "deleteExpiredConnections" checkbox
|
||||
deleteEolConnectionsId: 'pf-map-dialog-delete-connections-eol', // id for "deleteEOLConnections" checkbox
|
||||
|
||||
characterSelectId: 'pf-map-dialog-character-select', // id for "character" select
|
||||
corporationSelectId: 'pf-map-dialog-corporation-select', // id for "corporation" select
|
||||
@@ -106,6 +107,7 @@ define([
|
||||
let accessCorporation = [];
|
||||
let accessAlliance = [];
|
||||
let deleteExpiredConnections = true;
|
||||
let deleteEolConnections = true;
|
||||
|
||||
if(mapData !== false){
|
||||
// set current map information
|
||||
@@ -120,6 +122,7 @@ define([
|
||||
accessAlliance = mapData.config.access.alliance;
|
||||
|
||||
deleteExpiredConnections = mapData.config.deleteExpiredConnections;
|
||||
deleteEolConnections = mapData.config.deleteEolConnections;
|
||||
}
|
||||
|
||||
// render main dialog -----------------------------------------------------
|
||||
@@ -150,7 +153,9 @@ define([
|
||||
|
||||
// settings tab --------------
|
||||
deleteExpiredConnectionsId : config.deleteExpiredConnectionsId,
|
||||
deleteEolConnectionsId : config.deleteEolConnectionsId,
|
||||
deleteExpiredConnections: deleteExpiredConnections,
|
||||
deleteEolConnections: deleteEolConnections,
|
||||
|
||||
characterSelectId: config.characterSelectId,
|
||||
corporationSelectId: config.corporationSelectId,
|
||||
@@ -238,6 +243,9 @@ define([
|
||||
if( form.find('#' + config.deleteExpiredConnectionsId).length ){
|
||||
formData.deleteExpiredConnections = formData.hasOwnProperty('deleteExpiredConnections') ? parseInt( formData.deleteExpiredConnections ) : 0;
|
||||
}
|
||||
if( form.find('#' + config.deleteEolConnectionsId).length ){
|
||||
formData.deleteEolConnections = formData.hasOwnProperty('deleteEolConnections') ? parseInt( formData.deleteEolConnections ) : 0;
|
||||
}
|
||||
|
||||
let requestData = {formData: formData};
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ define([
|
||||
dialogMapSettingsContainerId: 'pf-map-dialog-settings', // id for the "settings" container
|
||||
dialogMapDownloadContainerId: 'pf-map-dialog-download', // id for the "download" container
|
||||
|
||||
deleteExpiredConnectionsId: 'pf-map-dialog-delete-connections', // id for "deleteExpiredConnections" checkbox
|
||||
deleteExpiredConnectionsId: 'pf-map-dialog-delete-connections-expired', // id for "deleteExpiredConnections" checkbox
|
||||
deleteEolConnectionsId: 'pf-map-dialog-delete-connections-eol', // id for "deleteEOLConnections" checkbox
|
||||
|
||||
characterSelectId: 'pf-map-dialog-character-select', // id for "character" select
|
||||
corporationSelectId: 'pf-map-dialog-corporation-select', // id for "corporation" select
|
||||
@@ -106,6 +107,7 @@ define([
|
||||
let accessCorporation = [];
|
||||
let accessAlliance = [];
|
||||
let deleteExpiredConnections = true;
|
||||
let deleteEolConnections = true;
|
||||
|
||||
if(mapData !== false){
|
||||
// set current map information
|
||||
@@ -120,6 +122,7 @@ define([
|
||||
accessAlliance = mapData.config.access.alliance;
|
||||
|
||||
deleteExpiredConnections = mapData.config.deleteExpiredConnections;
|
||||
deleteEolConnections = mapData.config.deleteEolConnections;
|
||||
}
|
||||
|
||||
// render main dialog -----------------------------------------------------
|
||||
@@ -150,7 +153,9 @@ define([
|
||||
|
||||
// settings tab --------------
|
||||
deleteExpiredConnectionsId : config.deleteExpiredConnectionsId,
|
||||
deleteEolConnectionsId : config.deleteEolConnectionsId,
|
||||
deleteExpiredConnections: deleteExpiredConnections,
|
||||
deleteEolConnections: deleteEolConnections,
|
||||
|
||||
characterSelectId: config.characterSelectId,
|
||||
corporationSelectId: config.corporationSelectId,
|
||||
@@ -238,6 +243,9 @@ define([
|
||||
if( form.find('#' + config.deleteExpiredConnectionsId).length ){
|
||||
formData.deleteExpiredConnections = formData.hasOwnProperty('deleteExpiredConnections') ? parseInt( formData.deleteExpiredConnections ) : 0;
|
||||
}
|
||||
if( form.find('#' + config.deleteEolConnectionsId).length ){
|
||||
formData.deleteEolConnections = formData.hasOwnProperty('deleteEolConnections') ? parseInt( formData.deleteEolConnections ) : 0;
|
||||
}
|
||||
|
||||
let requestData = {formData: formData};
|
||||
|
||||
|
||||
@@ -47,14 +47,23 @@
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-1 col-sm-11">
|
||||
<div class="col-sm-12 col-xs-6 checkbox checkbox-primary" title="remove expired EOL connections">
|
||||
<div class="col-sm-12 col-xs-6 checkbox" title="outdated WHs (~2 days)">
|
||||
<input id="{{deleteExpiredConnectionsId}}" name="deleteExpiredConnections" value="1" type="checkbox" {{#deleteExpiredConnections}}checked{{/deleteExpiredConnections}}>
|
||||
<label for="{{deleteExpiredConnectionsId}}">Auto delete expired connections</label>
|
||||
<label for="{{deleteExpiredConnectionsId}}">Auto delete outdated wormholes</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-1 col-sm-11">
|
||||
<div class="col-sm-12 col-xs-6 checkbox" title="expired EOL WHs (~4h 15min)">
|
||||
<input id="{{deleteEolConnectionsId}}" name="deleteEolConnections" value="1" type="checkbox" {{#deleteEolConnections}}checked{{/deleteEolConnections}}>
|
||||
<label for="{{deleteEolConnectionsId}}">Auto delete expired wormholes</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6"></div>
|
||||
</div>
|
||||
|
||||
<h4 class="pf-dynamic-area">Share settings</h4>
|
||||
|
||||
Reference in New Issue
Block a user