Files
fdn2/app/private/bin/convertStats.php
T
2022-09-11 10:16:29 +02:00

74 lines
1.9 KiB
PHP
Executable File

#!/usr/local/bin/php
<?php
/******************************************
* Author : Riccardo Di Dato
* Created On : Tue Aug 30 2022
* File : convertStats.php
*******************************************/
require_once(dirname(__FILE__)."/../load.php");
$iteration = 0;
function getModels() {
global $iteration;
$size = 1000;
$ret = GlobalVariables::get("dao")->query(
StatisticModel::class,
[],
[
'skip' => $iteration * $size,
'limit' => $size
]
);
$iteration++;
return $ret;
}
$models = getModels();
while (sizeof($models)>0) {
foreach ($models as $model) {
$ts = floor( strval($model->date) / 1000) ;
if ($model->statType == StatisticModel::STAT_TYPE_NOTIZIA) {
AnalyticsHelper::notiziaImpression(
$model->content,
date("d", $ts),
date("m", $ts),
date("Y", $ts)
);
}
else if ($model->statType == StatisticModel::STAT_TYPE_PAGE) {
AnalyticsHelper::pageImpression(
$model->content->notizia,
date("d", $ts),
date("m", $ts),
date("Y", $ts),
$model->user->isNew
);
}
else if ($model->statType == StatisticModel::STAT_TYPE_BANNER_CLICK) {
AnalyticsHelper::bannerClick(
$model->content->banner,
date("d", $ts),
date("m", $ts),
date("Y", $ts)
);
}
else if ($model->statType == StatisticModel::STAT_TYPE_BANNER_IMPRESSION) {
AnalyticsHelper::bannerImpression(
$model->content->banner,
date("d", $ts),
date("m", $ts),
date("Y", $ts)
);
}
}
echo "Completed iteration $iteration", PHP_EOL;
$models = getModels();
}
?>