gpt
This commit is contained in:
parent
0c32da87a9
commit
e5fa6f0b76
|
|
@ -783,6 +783,22 @@ def insert_usefulinfo_record(parsed):
|
|||
pass
|
||||
print("[usefulinfo][tag-link-failed] summary_id=", summary_id, " tag=", t, " error=", str(ex_tag_link))
|
||||
|
||||
# Determine schema variant for events (legacy column vs link table)
|
||||
has_event_summary_col = False
|
||||
has_link_table = True
|
||||
try:
|
||||
CUR.execute("SELECT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='useful_info_event' AND column_name='summary_id')")
|
||||
row = CUR.fetchone()
|
||||
has_event_summary_col = bool(row[0]) if row else False
|
||||
except Exception as ex_chk1:
|
||||
print('[usefulinfo][diag] failed to probe useful_info_event.summary_id:', str(ex_chk1))
|
||||
try:
|
||||
CUR.execute("SELECT to_regclass('useful_info_summary_event')")
|
||||
row = CUR.fetchone()
|
||||
has_link_table = bool(row and row[0])
|
||||
except Exception as ex_chk2:
|
||||
print('[usefulinfo][diag] failed to probe useful_info_summary_event presence:', str(ex_chk2))
|
||||
|
||||
# Events
|
||||
if summary_id and isinstance(events, list):
|
||||
for idx, e in enumerate(events, start=1):
|
||||
|
|
@ -830,6 +846,16 @@ def insert_usefulinfo_record(parsed):
|
|||
|
||||
try:
|
||||
CUR.execute("SAVEPOINT sp_event")
|
||||
if has_event_summary_col:
|
||||
CUR.execute(
|
||||
"""
|
||||
INSERT INTO useful_info_event (summary_id, dt, length, title, description)
|
||||
VALUES (%s, %s, %s, %s, %s)
|
||||
RETURNING id
|
||||
""",
|
||||
(summary_id, raw_dt, raw_len, raw_title, raw_desc)
|
||||
)
|
||||
else:
|
||||
CUR.execute(
|
||||
"""
|
||||
INSERT INTO useful_info_event (dt, length, title, description)
|
||||
|
|
@ -840,6 +866,7 @@ def insert_usefulinfo_record(parsed):
|
|||
)
|
||||
evrow = CUR.fetchone()
|
||||
if evrow and evrow[0]:
|
||||
if has_link_table:
|
||||
try:
|
||||
CUR.execute("SAVEPOINT sp_evlink")
|
||||
CUR.execute(
|
||||
|
|
|
|||
Loading…
Reference in New Issue