Skip to content

Commit

Permalink
Add comments, fix little issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunnyka98 committed Aug 2, 2023
1 parent 5427912 commit 3bb8509
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions CSVZipExport/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function Export(int $ArchiveVariable, int $AggregationStage, string $Aggr
while ($loopAgain) {
$content = '';
if ($AggregationStage != 7) {
$loggedValues = AC_GetAggregatedValues($archiveControlID, $ArchiveVariable, $AggregationStage, $startTimeStamp, $endTimeStamp - 1, $limit);
$loggedValues = AC_GetAggregatedValues($archiveControlID, $ArchiveVariable, $AggregationStage, $startTimeStamp, $endTimeStamp, $limit);
$loopAgain = count($loggedValues) == $limit;
for ($j = 0; $j < count($loggedValues); $j++) {
$content .= date('d.m.Y H:i:s', $loggedValues[$j]['TimeStamp']) . ';' . $loggedValues[$j]['Avg'] . "\n";
Expand All @@ -122,10 +122,9 @@ public function Export(int $ArchiveVariable, int $AggregationStage, string $Aggr
$loopAgain = count($loggedValues) == $limit;

//Protect values to duplicate on limit border
//endElements are the last element on the previous array
foreach ($endElements as $element) {
if ($element == reset($loggedValues)) {
array_shift($loggedValues);
}
array_shift($loggedValues);
}

for ($j = 0; $j < count($loggedValues); $j++) {
Expand All @@ -136,10 +135,16 @@ public function Export(int $ArchiveVariable, int $AggregationStage, string $Aggr

if ($loopAgain) {
$endTimeStamp = end($loggedValues)['TimeStamp'];
$endElements = array_filter($loggedValues, function ($element) use ($endTimeStamp)
{
return $element['TimeStamp'] == $endTimeStamp;
});

if ($AggregationStage != 7) {
$endTimeStamp -= 1;
} else {
//Only logged values can have duplicates on the same timestamp
$endElements = array_filter($loggedValues, function ($element) use ($endTimeStamp)
{
return $element['TimeStamp'] == $endTimeStamp;
});
}
}
}

Expand Down

0 comments on commit 3bb8509

Please sign in to comment.