remove time graph visualiser. More tests. Other fixes
Some checks failed
Lint / test (push) Waiting to run
Trivy / test (push) Waiting to run
CI / test (push) Has been cancelled

This commit is contained in:
Miguel Jacq 2025-11-19 15:33:31 +11:00
parent 0b3249c7ef
commit 985541a1d8
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
18 changed files with 4087 additions and 971 deletions

View file

@ -790,49 +790,6 @@ class DBManager:
revisions_by_date,
)
def get_tag_cooccurrences(self):
"""
Compute tagtag co-occurrence across pages.
Returns:
tags_by_id: dict[int, TagRow] # id -> (id, name, color)
edges: list[(int, int, int)] # (tag_id1, tag_id2, page_count)
tag_page_counts: dict[int, int] # tag_id -> number of pages it appears on
"""
cur = self.conn.cursor()
# 1) All tags (reuse existing helper)
all_tags: list[TagRow] = self.list_tags()
tags_by_id: dict[int, TagRow] = {t[0]: t for t in all_tags}
# 2) How many pages each tag appears on (for node sizing)
rows = cur.execute(
"""
SELECT tag_id, COUNT(DISTINCT page_date) AS c
FROM page_tags
GROUP BY tag_id;
"""
).fetchall()
tag_page_counts = {r["tag_id"]: r["c"] for r in rows}
# 3) Co-occurrence of tag pairs on the same page
rows = cur.execute(
"""
SELECT
pt1.tag_id AS tag1,
pt2.tag_id AS tag2,
COUNT(DISTINCT pt1.page_date) AS c
FROM page_tags AS pt1
JOIN page_tags AS pt2
ON pt1.page_date = pt2.page_date
AND pt1.tag_id < pt2.tag_id
GROUP BY pt1.tag_id, pt2.tag_id;
""",
).fetchall()
edges = [(r["tag1"], r["tag2"], r["c"]) for r in rows]
return tags_by_id, edges, tag_page_counts
# -------- Time logging: projects & activities ---------------------
def list_projects(self) -> list[ProjectRow]:
@ -1037,7 +994,7 @@ class DBManager:
AND t.page_date BETWEEN ? AND ?
GROUP BY bucket, activity_name
ORDER BY bucket, LOWER(activity_name);
""", # nosec B608: bucket_expr comes from a fixed internal list
""", # nosec
(project_id, start_date_iso, end_date_iso),
).fetchall()