.
This commit is contained in:
@@ -216,9 +216,17 @@ def _rich_html_with_images(html: str) -> str:
|
||||
return _IMG_PLACEHOLDER_RE.sub(sub, html)
|
||||
|
||||
|
||||
def _fmt_ts(value, n: int = 19) -> str:
|
||||
return str(value)[:n] if value else ""
|
||||
|
||||
|
||||
def _row_to_dict(cols, r, *, full_text: bool = False) -> dict:
|
||||
d = dict(zip(cols, r))
|
||||
d["updated_at"] = str(d["updated_at"])[:16] if d["updated_at"] else ""
|
||||
d["updated_at"] = _fmt_ts(d.get("updated_at"), 16)
|
||||
if "created_at" in d:
|
||||
d["created_at"] = _fmt_ts(d.get("created_at"))
|
||||
if "processed_at" in d:
|
||||
d["processed_at"] = _fmt_ts(d.get("processed_at"))
|
||||
try:
|
||||
d["images"] = json.loads(d["images"]) if d.get("images") else []
|
||||
except Exception:
|
||||
@@ -251,9 +259,9 @@ def fetch_sections(
|
||||
conn = db_conn()
|
||||
cur = conn.cursor()
|
||||
sql = """
|
||||
SELECT s.prefix, s.code, s.title, s.keywords, s.char_count,
|
||||
s.source_file, s.output_path, s.updated_at,
|
||||
s.images, s.html_text, f.section_count
|
||||
SELECT s.id, s.prefix, s.code, s.title, s.keywords, s.char_count,
|
||||
s.source_file, s.output_path, s.updated_at, s.created_at,
|
||||
f.processed_at, s.images, s.html_text, f.section_count
|
||||
FROM rip_help_sections s
|
||||
LEFT JOIN rip_help_files f
|
||||
ON f.file_path = s.source_file AND f.prefix = s.prefix
|
||||
@@ -353,9 +361,9 @@ def api_section(code: str):
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT s.prefix, s.code, s.title, s.keywords, s.char_count,
|
||||
s.source_file, s.output_path, s.updated_at,
|
||||
s.images, s.html_text, f.section_count
|
||||
SELECT s.id, s.prefix, s.code, s.title, s.keywords, s.char_count,
|
||||
s.source_file, s.output_path, s.updated_at, s.created_at,
|
||||
f.processed_at, s.images, s.html_text, f.section_count
|
||||
FROM rip_help_sections s
|
||||
LEFT JOIN rip_help_files f
|
||||
ON f.file_path = s.source_file AND f.prefix = s.prefix
|
||||
|
||||
Reference in New Issue
Block a user