Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Fix #26
Browse files Browse the repository at this point in the history
  • Loading branch information
kimbtech committed Sep 22, 2020
1 parent f2a7149 commit a8cfa7e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
class Utilities {

const VERSION = 'v1.0.0 rc3';
const VERSION = 'v1.0.0 rc4';

/**
* OS Consts
Expand Down
3 changes: 2 additions & 1 deletion core/sync/DirectoryStatsAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public function __construct(){
$this->thisClientName = $c->getValue(['sync', 'directory', 'thisname']);
}

protected function listFilesUnfiltered() : array {
protected function listFilesUnfiltered( int $timeMin, int $timeMax ) : array {
// No filtertering for $timeMax, $timeMin cause only minimal speedup
$files = array();
foreach(array_diff(scandir($this->directory), ['.','..']) as $dir ){
if( $dir !== $this->thisClientName && is_dir($this->directory . '/' . $dir) ){
Expand Down
3 changes: 2 additions & 1 deletion core/sync/LocalStatsAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

class LocalStatsAccess extends StatsAccess {

protected function listFilesUnfiltered() : array {
protected function listFilesUnfiltered( int $timeMin, int $timeMax ) : array {
// No filtertering for $timeMax, $timeMin cause only minimal speedup
return array_map( function ($f) {
return array(
'timestamp' => strtotime(substr($f, 0, -5)),
Expand Down
10 changes: 8 additions & 2 deletions core/sync/ServerStatsAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ private function postToServer(string $endpoint, array $data = array() ) : array
return array();
}

protected function listFilesUnfiltered() : array {
return $this->postToServer('list');
protected function listFilesUnfiltered(int $timeMin, int $timeMax) : array {
// Filtertering cause reduces server response size
return $this->postToServer(
'list',
array(
'timeMin' => $timeMin,
'timeMax' => $timeMax
));
}

protected function getFileUnfiltered( string $file, string $device ) : array {
Expand Down
9 changes: 6 additions & 3 deletions core/sync/StatsAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ abstract class StatsAccess {
* 'device' => '' // device to pass to getFile()
* ), ...)
*
* @param $timeMin the minimal timestamp the retuned file my have
* @param $timeMax the maximal timestamp the retuned file my have
* Filtering for timeMin, timeMax is optional!!
* Must not return stats of the client itself!
*/
public function listFiles() : array {
return $this->filterFileList($this->listFilesUnfiltered());
public function listFiles( int $timeMin, int $timeMax ) : array {
return $this->filterFileList($this->listFilesUnfiltered( $timeMin, $timeMax ));
}
abstract protected function listFilesUnfiltered() : array;
abstract protected function listFilesUnfiltered(int $timeMin, int $timeMax) : array;

/**
* return array like JSON in e.g. "2020-02-12.json"
Expand Down
2 changes: 1 addition & 1 deletion core/sync/StatsLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(int $time, int $forwardTo, bool $localOnly){

private function selectUntil() : void {
foreach( $this->locations as $location => $access ){
foreach( $access->listFiles() as $file ){
foreach( $access->listFiles( $this->untilDay, $this->forward ) as $file ){
if( $file['timestamp'] >= $this->untilDay && $file['timestamp'] <= $this->forward){
$this->filelist[] = array(
'file' => $file['file'],
Expand Down

0 comments on commit a8cfa7e

Please sign in to comment.