feat: add broken links table generation
This commit is contained in:
parent
03c0643ae7
commit
159eb6c879
2 changed files with 20 additions and 0 deletions
|
|
@ -67,6 +67,15 @@ class TableService(SqliteService):
|
|||
"target_entry_title": link,
|
||||
},
|
||||
)
|
||||
else:
|
||||
self._execute(
|
||||
"INSERT OR IGNORE INTO broken_links (source_entry_title, broken_link_title) VALUES (:source_entry_title, :broken_link_title)",
|
||||
{
|
||||
"source_entry_title": entry.get("title"),
|
||||
"broken_link_title": link,
|
||||
},
|
||||
)
|
||||
print("TB-INFO Junction tables populated")
|
||||
|
||||
def __populate_fts_tables(self):
|
||||
self._execute("INSERT INTO entries_fts(entries_fts) VALUES('rebuild')")
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ CREATE TABLE IF NOT EXISTS backlinks (
|
|||
)
|
||||
"""
|
||||
|
||||
|
||||
CREATE_ENTRIES_TAGS_TABLE = """
|
||||
CREATE TABLE IF NOT EXISTS entries_tags (
|
||||
entry_title TEXT,
|
||||
|
|
@ -32,6 +33,15 @@ CREATE TABLE IF NOT EXISTS entries_tags (
|
|||
PRIMARY KEY (entry_title, tag_name)
|
||||
)"""
|
||||
|
||||
CREATE_BROKEN_LINKS_TABLE = """
|
||||
CREATE TABLE IF NOT EXISTS broken_links (
|
||||
source_entry_title TEXT, broken_link_title TEXT,
|
||||
FOREIGN KEY (source_entry_title) REFERENCES entries(title),
|
||||
PRIMARY KEY (source_entry_title, broken_link_title)
|
||||
)
|
||||
"""
|
||||
|
||||
|
||||
CREATE_ENTRIES_FTS_TABLE = """
|
||||
CREATE VIRTUAL TABLE entries_fts USING fts5(title, body, content=entries, content_rowid=rowid)
|
||||
"""
|
||||
|
|
@ -43,4 +53,5 @@ tables = [
|
|||
{"name": "backlinks", "create_statement": CREATE_BACKLINKS_TABLE},
|
||||
{"name": "entries_tags", "create_statement": CREATE_ENTRIES_TAGS_TABLE},
|
||||
{"name": "entries_fts", "create_statement": CREATE_ENTRIES_FTS_TABLE},
|
||||
{"name": "broken_links", "create_statement": CREATE_BROKEN_LINKS_TABLE},
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue