1 | <?php declare(strict_types=1); |
||
12 | class FileSource implements SourceInterface |
||
13 | { |
||
14 | const SELECT_LIMIT = 1440; |
||
15 | |||
16 | /** @var string */ |
||
17 | protected $path; |
||
18 | /** @var DataPackerInterface */ |
||
19 | protected $DataPacker; |
||
20 | |||
21 | 5 | public function __construct(string $path, DataPackerInterface $DataPacker) |
|
26 | |||
27 | 1 | public function getSnapshotsDataByDates(string $datetime_from, string $datetime_to): array |
|
58 | |||
59 | 2 | public function getPerfData(string $app, string $label, string $date): array |
|
60 | { |
||
61 | 2 | $perf_data = []; |
|
62 | 2 | $dir = $this->path . '/' . $app . '/' . base64_encode($label); |
|
63 | 2 | if (is_dir($dir)) { |
|
64 | 1 | $files = scandir($dir, SCANDIR_SORT_NONE); |
|
65 | 1 | foreach ($files as $file) { |
|
66 | 1 | if ($file === '.' || $file === '..') { |
|
67 | 1 | continue; |
|
68 | } |
||
69 | 1 | $timestamp = (int)str_replace('.json', '', $file); |
|
70 | 1 | if ($timestamp >= strtotime($date . ' 00:00:00') && $timestamp <= strtotime($date . ' 23:59:59')) { |
|
71 | 1 | $perf_data[] = file_get_contents($dir . '/' . $file); |
|
72 | 1 | if (count($perf_data) >= self::SELECT_LIMIT + 1) { |
|
73 | break; |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 | } |
||
78 | |||
79 | 2 | return $perf_data; |
|
80 | } |
||
81 | |||
82 | 1 | public function getLabelList(): array |
|
99 | |||
100 | 3 | public function getAppList(): array |
|
112 | } |
||
113 |