|
|
@@ -643,8 +643,9 @@ class SQLiteClusterStore:
|
|
|
) -> list[dict[str, Any]]:
|
|
|
"""Paginated cluster listing for the dashboard."""
|
|
|
cutoff = (datetime.now(timezone.utc) - timedelta(hours=hours)).isoformat()
|
|
|
- query = "SELECT payload FROM clusters WHERE updated_at >= ?"
|
|
|
- params: list = [cutoff]
|
|
|
+ now = datetime.now(timezone.utc).isoformat()
|
|
|
+ query = "SELECT payload FROM clusters WHERE updated_at >= ? AND updated_at <= ?"
|
|
|
+ params: list = [cutoff, now]
|
|
|
if topic and topic != "all":
|
|
|
query += " AND topic = ?"
|
|
|
params.append(topic)
|
|
|
@@ -679,8 +680,9 @@ class SQLiteClusterStore:
|
|
|
) -> list[dict[str, Any]]:
|
|
|
"""Sentiment score averaged per time bucket."""
|
|
|
cutoff = (datetime.now(timezone.utc) - timedelta(hours=hours)).isoformat()
|
|
|
- query = "SELECT payload FROM clusters WHERE updated_at >= ?"
|
|
|
- params: list = [cutoff]
|
|
|
+ now = datetime.now(timezone.utc).isoformat()
|
|
|
+ query = "SELECT payload FROM clusters WHERE updated_at >= ? AND updated_at <= ?"
|
|
|
+ params: list = [cutoff, now]
|
|
|
if topic and topic != "all":
|
|
|
query += " AND topic = ?"
|
|
|
params.append(topic)
|
|
|
@@ -737,10 +739,11 @@ class SQLiteClusterStore:
|
|
|
) -> list[dict[str, Any]]:
|
|
|
"""Top entities by mention count in recent clusters."""
|
|
|
cutoff = (datetime.now(timezone.utc) - timedelta(hours=hours)).isoformat()
|
|
|
+ now = datetime.now(timezone.utc).isoformat()
|
|
|
with self._conn() as conn:
|
|
|
cur = conn.execute(
|
|
|
- "SELECT payload FROM clusters WHERE updated_at >= ? ORDER BY updated_at DESC LIMIT 500",
|
|
|
- (cutoff,),
|
|
|
+ "SELECT payload FROM clusters WHERE updated_at >= ? AND updated_at <= ? ORDER BY updated_at DESC LIMIT 500",
|
|
|
+ (cutoff, now),
|
|
|
)
|
|
|
rows = cur.fetchall()
|
|
|
counter: dict[str, int] = {}
|