Commit 74422526 authored by dmorley's avatar dmorley

check lang >1 day using meta table

parent 9a8e053f
Pipeline #577 passed with stage
in 1 minute and 50 seconds
......@@ -12,7 +12,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
## [2.5.0]
:exclamation: DB migrations required! (see [SQL migration script][2.5.0-sql-migration])
### Added
- Status table, monitor status of events happening
- Meta data table for status and misc storage
### Changed
- Status page is now /status from /db/status.php
### Deprecated
......
......@@ -4,3 +4,4 @@ CREATE TABLE meta (
value text,
date_created timestamp DEFAULT current_timestamp
);
INSERT INTO meta (name) VALUES('languages_updated');
\ No newline at end of file
......@@ -249,6 +249,21 @@ foreach ($pods as $pod) {
$status = PodStatus::UP;
}
try {
$updbstatus = R::getRow("
SELECT date_created
FROM meta
WHERE name = 'languages_updated'
ORDER BY id DESC
LIMIT 1
");
} catch (\RedBeanPHP\RedException $e) {
die('Status Red Error in SQL query: ' . $e->getMessage());
}
$langdiff = (new DateTime())->diff(new DateTime($updbstatus['date_created']));
$langdays = $langdiff->days;
// Default to the already saved language.
$detectedlanguage = $language;
......@@ -257,8 +272,9 @@ foreach ($pods as $pod) {
$detectedlanguage = null;
--$score;
$podminhelp = 'Unable to render the html on your main page https://' . $domain;
} elseif ($debug || Carbon::now()->hour === 12) {
} elseif ($debug || $langdays > 1) {
$detectedlanguage = detectWebsiteLanguageFromSnippet($language_snippet);
$languagesupdated = true;
}
debug('Detected Language', $detectedlanguage);
......@@ -434,3 +450,4 @@ updateMeta('pods_updated');
$time_end = microtime(true);
$execution_time = ($time_end - $time_start)/60;
updateMeta('pods_update_runtime', round($execution_time));
$languagesupdated ?: updateMeta('languages_updated');
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment