mirror of
https://github.com/myronblair/jarvis
synced 2026-06-30 17:50:23 -05:00
fix: storeFact always bumps updated_at; fix $fresh() wrong column name
ON DUPLICATE KEY UPDATE was not touching updated_at, so if a site's status didn't change MySQL never fired the ON UPDATE trigger and the row timestamp stayed 6 days stale. do_server.php's 15-min freshness window then returned empty sites. Also fixes $fresh() querying WHERE fact_category= (non-existent column) instead of WHERE category=, which always returned no rows. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,7 @@ function collect_all(): array {
|
|||||||
// Prevents expensive external calls when data is still fresh.
|
// Prevents expensive external calls when data is still fresh.
|
||||||
$fresh = function(string $cat, int $secs): bool {
|
$fresh = function(string $cat, int $secs): bool {
|
||||||
$row = JarvisDB::query(
|
$row = JarvisDB::query(
|
||||||
'SELECT updated_at FROM kb_facts WHERE fact_category=? ORDER BY updated_at DESC LIMIT 1',
|
'SELECT updated_at FROM kb_facts WHERE category=? ORDER BY updated_at DESC LIMIT 1',
|
||||||
[$cat]
|
[$cat]
|
||||||
);
|
);
|
||||||
if (empty($row[0]['updated_at'])) return false;
|
if (empty($row[0]['updated_at'])) return false;
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class KBEngine {
|
|||||||
JarvisDB::execute(
|
JarvisDB::execute(
|
||||||
'INSERT INTO kb_facts (category, fact_key, fact_value, host, expires_at)
|
'INSERT INTO kb_facts (category, fact_key, fact_value, host, expires_at)
|
||||||
VALUES (?,?,?,?,?)
|
VALUES (?,?,?,?,?)
|
||||||
ON DUPLICATE KEY UPDATE fact_value=VALUES(fact_value), expires_at=VALUES(expires_at)',
|
ON DUPLICATE KEY UPDATE fact_value=VALUES(fact_value), expires_at=VALUES(expires_at), updated_at=NOW()',
|
||||||
[$category, $key, $value, $host, $expires]
|
[$category, $key, $value, $host, $expires]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user