|
@@ -314,6 +314,10 @@ class SQLiteClusterStore:
|
|
|
conn.execute("ALTER TABLE feed_state ADD COLUMN enabled INTEGER DEFAULT 1")
|
|
conn.execute("ALTER TABLE feed_state ADD COLUMN enabled INTEGER DEFAULT 1")
|
|
|
except sqlite3.OperationalError:
|
|
except sqlite3.OperationalError:
|
|
|
pass
|
|
pass
|
|
|
|
|
+ try:
|
|
|
|
|
+ conn.execute("ALTER TABLE feed_state ADD COLUMN re_enrich INTEGER DEFAULT 0")
|
|
|
|
|
+ except sqlite3.OperationalError:
|
|
|
|
|
+ pass
|
|
|
|
|
|
|
|
conn.execute(
|
|
conn.execute(
|
|
|
"""
|
|
"""
|
|
@@ -470,7 +474,7 @@ class SQLiteClusterStore:
|
|
|
"""All feed_state rows."""
|
|
"""All feed_state rows."""
|
|
|
with self._conn() as conn:
|
|
with self._conn() as conn:
|
|
|
cur = conn.execute(
|
|
cur = conn.execute(
|
|
|
- "SELECT feed_key, last_hash, last_item_count, enabled, updated_at FROM feed_state ORDER BY updated_at DESC"
|
|
|
|
|
|
|
+ "SELECT feed_key, last_hash, last_item_count, enabled, re_enrich, updated_at FROM feed_state ORDER BY updated_at DESC"
|
|
|
)
|
|
)
|
|
|
return [
|
|
return [
|
|
|
{
|
|
{
|
|
@@ -478,7 +482,8 @@ class SQLiteClusterStore:
|
|
|
"last_hash": row[1],
|
|
"last_hash": row[1],
|
|
|
"last_item_count": row[2],
|
|
"last_item_count": row[2],
|
|
|
"enabled": bool(row[3]),
|
|
"enabled": bool(row[3]),
|
|
|
- "updated_at": row[4],
|
|
|
|
|
|
|
+ "re_enrich": bool(row[4]),
|
|
|
|
|
+ "updated_at": row[5],
|
|
|
}
|
|
}
|
|
|
for row in cur.fetchall()
|
|
for row in cur.fetchall()
|
|
|
]
|
|
]
|
|
@@ -490,7 +495,7 @@ class SQLiteClusterStore:
|
|
|
with self._conn() as conn:
|
|
with self._conn() as conn:
|
|
|
for url in feed_urls:
|
|
for url in feed_urls:
|
|
|
conn.execute(
|
|
conn.execute(
|
|
|
- "INSERT OR IGNORE INTO feed_state(feed_key, last_hash, last_item_count, enabled, updated_at) VALUES(?, '', 0, 1, '')",
|
|
|
|
|
|
|
+ "INSERT OR IGNORE INTO feed_state(feed_key, last_hash, last_item_count, enabled, re_enrich, updated_at) VALUES(?, '', 0, 1, 0, '')",
|
|
|
(url,),
|
|
(url,),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -507,6 +512,26 @@ class SQLiteClusterStore:
|
|
|
)
|
|
)
|
|
|
return cur.rowcount > 0
|
|
return cur.rowcount > 0
|
|
|
|
|
|
|
|
|
|
+ def set_feed_re_enrich(self, feed_url: str, re_enrich: bool) -> bool:
|
|
|
|
|
+ """Toggle per-feed re-enrichment. Returns True if the feed existed and was updated."""
|
|
|
|
|
+ with self._conn() as conn:
|
|
|
|
|
+ cur = conn.execute(
|
|
|
|
|
+ "UPDATE feed_state SET re_enrich = ? WHERE feed_key = ?",
|
|
|
|
|
+ (1 if re_enrich else 0, feed_url),
|
|
|
|
|
+ )
|
|
|
|
|
+ return cur.rowcount > 0
|
|
|
|
|
+
|
|
|
|
|
+ def is_re_enrich_enabled(self, feed_url: str) -> bool:
|
|
|
|
|
+ """Return True if re-enrichment is enabled for the given feed_url."""
|
|
|
|
|
+ with self._conn() as conn:
|
|
|
|
|
+ cur = conn.execute(
|
|
|
|
|
+ "SELECT re_enrich FROM feed_state WHERE feed_key = ?", (feed_url,)
|
|
|
|
|
+ )
|
|
|
|
|
+ row = cur.fetchone()
|
|
|
|
|
+ if row is None:
|
|
|
|
|
+ return False # unknown feed → disabled
|
|
|
|
|
+ return bool(row[0])
|
|
|
|
|
+
|
|
|
def get_enabled_feed_urls(self, feed_urls: list[str]) -> list[str]:
|
|
def get_enabled_feed_urls(self, feed_urls: list[str]) -> list[str]:
|
|
|
"""From a list of configured feed URLs, return only those that are enabled in feed_state.
|
|
"""From a list of configured feed URLs, return only those that are enabled in feed_state.
|
|
|
|
|
|
|
@@ -788,11 +813,11 @@ class SQLiteClusterStore:
|
|
|
last_refresh = self.get_meta("last_refresh_at")
|
|
last_refresh = self.get_meta("last_refresh_at")
|
|
|
feeds = {}
|
|
feeds = {}
|
|
|
for row in conn.execute(
|
|
for row in conn.execute(
|
|
|
- "SELECT feed_key, last_hash, last_item_count, enabled, updated_at FROM feed_state ORDER BY updated_at DESC"
|
|
|
|
|
|
|
+ "SELECT feed_key, last_hash, last_item_count, enabled, re_enrich, updated_at FROM feed_state ORDER BY updated_at DESC"
|
|
|
):
|
|
):
|
|
|
feeds[row[0]] = {
|
|
feeds[row[0]] = {
|
|
|
"last_hash": row[1], "last_item_count": row[2],
|
|
"last_hash": row[1], "last_item_count": row[2],
|
|
|
- "enabled": bool(row[3]), "updated_at": row[4],
|
|
|
|
|
|
|
+ "enabled": bool(row[3]), "re_enrich": bool(row[4]), "updated_at": row[5],
|
|
|
}
|
|
}
|
|
|
# Freshness: did a refresh happen recently? (within 2x the configured interval)
|
|
# Freshness: did a refresh happen recently? (within 2x the configured interval)
|
|
|
fresh = False
|
|
fresh = False
|