Files
pathfinder/app/main/cron/statisticsupdate.php
Exodus4D b2cce3cde2 - new "activity log" for user actions (create/update/delete) of (systems/connections/signatures), resolves #280, relates #271
- new added cronjob to delete old statistics data (older 1 year) (weekly)
- updated main menu structure (added new headlines,...)
- updated "feature page", added new section for "statistics"
- updated "system delete" function. systems with no changes (description/alias) will now get deleted instead of set "active = 0", #184
- changed max expire time from file caching (/tmp/cache) from 20d -> 10d
- changed "character log" TTL from 10s to 5s
- changed cronjob interval for "deleteExpiredData" from "weekly" to "downtime"
- changed "delete" icon (e.g. context menu on map) from "eraser" to "trash"
- removed cronjob output logging (cron_deactivateMapData.log)
- fixed non click-able character panels on login page, closed #332
2016-10-17 14:01:46 +02:00

46 lines
1.1 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: Exodus
* Date: 16.10.2016
* Time: 21:31
*/
namespace cron;
use DB;
class StatisticsUpdate {
const LOG_TEXT_STATISTICS = '%s (%d rows)';
/**
* delete old statistics
* -> older than 1 year
* >> php index.php "/cron/deleteStatisticsData"
* @param \Base $f3
*/
function deleteStatisticsData(\Base $f3){
$currentYear = (int)date('o');
$currentWeek = (int)date('W');
$expiredYear = $currentYear - 1;
$pfDB = DB\Database::instance()->getDB('PF');
$queryData = [
'yearWeekEnd' => strval($expiredYear) . str_pad($currentWeek, 2, 0, STR_PAD_LEFT)
];
$sql = "DELETE FROM
activity_log
WHERE
CONCAT(`year`, `week`) < :yearWeekEnd";
$pfDB->exec($sql, $queryData);
$deletedLogsCount = $pfDB->count();
// Log ------------------------
$log = new \Log('cron_' . __FUNCTION__ . '.log');
$log->write( sprintf(self::LOG_TEXT_STATISTICS, __FUNCTION__, $deletedLogsCount) );
}
}