2020-01-14 22:25:43 +01:00
|
|
|
<?php
|
2018-01-27 00:28:32 +01:00
|
|
|
|
2020-01-15 02:50:23 +01:00
|
|
|
require_once (__DIR__ . '/../../extern/egg/ExtendedGitGraph2.php');
|
2022-10-16 15:53:52 +02:00
|
|
|
require_once (__DIR__ . '/../iwebsitemodule.php');
|
2018-01-27 00:28:32 +01:00
|
|
|
|
2020-01-19 13:16:40 +01:00
|
|
|
class MikescherGitGraph implements IWebsiteModule
|
2018-01-27 00:28:32 +01:00
|
|
|
{
|
2020-01-15 00:57:11 +01:00
|
|
|
/** @var ExtendedGitGraph2 */
|
2022-10-16 15:53:52 +02:00
|
|
|
private ExtendedGitGraph2 $extgitgraph;
|
2018-01-27 00:28:32 +01:00
|
|
|
|
2020-01-15 00:57:11 +01:00
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */
|
2022-10-16 15:53:52 +02:00
|
|
|
public function __construct(array $egh_conf)
|
2020-01-15 00:57:11 +01:00
|
|
|
{
|
2022-10-16 15:53:52 +02:00
|
|
|
$this->extgitgraph = new ExtendedGitGraph2($egh_conf);
|
2018-01-27 00:28:32 +01:00
|
|
|
}
|
2018-01-27 14:21:34 +01:00
|
|
|
|
2022-10-16 15:53:52 +02:00
|
|
|
public function getPathRenderedData(): string
|
2018-01-27 14:21:34 +01:00
|
|
|
{
|
2020-01-15 02:50:23 +01:00
|
|
|
return __DIR__ . '/../../dynamic/egg/cache_fullrenderer.html';
|
2018-01-27 14:21:34 +01:00
|
|
|
}
|
|
|
|
|
2022-10-16 15:53:52 +02:00
|
|
|
public function update(): bool
|
2020-01-16 13:21:14 +01:00
|
|
|
{
|
|
|
|
return $this->extgitgraph->update();
|
|
|
|
}
|
|
|
|
|
2022-10-16 15:53:52 +02:00
|
|
|
public function updateCache(): ?string
|
2020-01-16 13:21:14 +01:00
|
|
|
{
|
|
|
|
return $this->extgitgraph->updateCache();
|
|
|
|
}
|
|
|
|
|
2019-12-28 14:00:11 +01:00
|
|
|
/**
|
|
|
|
* @return string|null
|
|
|
|
*/
|
2022-10-16 15:53:52 +02:00
|
|
|
public function get(): ?string
|
2018-01-27 14:21:34 +01:00
|
|
|
{
|
2020-01-15 00:57:11 +01:00
|
|
|
$d = $this->extgitgraph->loadFromCache();
|
2019-12-28 14:00:11 +01:00
|
|
|
if ($d === null) return "";
|
|
|
|
return $d;
|
2018-01-27 14:21:34 +01:00
|
|
|
}
|
|
|
|
|
2022-10-16 15:53:52 +02:00
|
|
|
public function checkConsistency(): array
|
2018-01-27 14:21:34 +01:00
|
|
|
{
|
2020-01-15 02:50:23 +01:00
|
|
|
$p = $this->getPathRenderedData();
|
2018-01-27 14:21:34 +01:00
|
|
|
|
2018-02-03 14:43:41 +01:00
|
|
|
if (!file_exists($p)) return ['result'=>'err', 'message' => 'Rendered data not found'];
|
2018-01-27 14:21:34 +01:00
|
|
|
|
2020-01-09 12:50:08 +01:00
|
|
|
if (filemtime($p) < time()-(24*60*60)) return ['result'=>'warn', 'message' => 'Rendered data is older than 1 day'];
|
2018-01-27 14:21:34 +01:00
|
|
|
|
|
|
|
return ['result'=>'ok', 'message' => ''];
|
|
|
|
}
|
2022-10-20 14:56:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string[]
|
|
|
|
*/
|
|
|
|
public function checkDatabaseConsistency(): array
|
|
|
|
{
|
|
|
|
return $this->extgitgraph->checkDatabase();
|
|
|
|
}
|
2018-01-27 00:28:32 +01:00
|
|
|
}
|