Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 03-Export-Tags-Authors-Stories.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def write_csv(data, filename, columns):
cols["ao3_tag_category"],
cols["original_description"],
"TW Notes",
"Used in Archive?",
],
)

Expand Down
30 changes: 19 additions & 11 deletions shared_python/Tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,24 @@ def distinct_tags(self, database):
database,
"""
SELECT DISTINCT
id as "Original Tag ID",
original_tag as "Original Tag Name",
original_type as "Original Tag Type",
original_parent as "Original Parent Tag",
ao3_tag_fandom as "Related Fandom",
ao3_tag as "Recommended AO3 Tag",
ao3_tag_type as "Recommended AO3 Type",
ao3_tag_category as "Recommended AO3 Category",
original_description as "Original Description",
'' as "TW Notes" FROM tags
t.id as "Original Tag ID",
t.original_tag as "Original Tag Name",
t.original_type as "Original Tag Type",
t.original_parent as "Original Parent Tag",
t.ao3_tag_fandom as "Related Fandom",
t.ao3_tag as "Recommended AO3 Tag",
t.ao3_tag_type as "Recommended AO3 Type",
t.ao3_tag_category as "Recommended AO3 Category",
t.original_description as "Original Description",
'' as "TW Notes",
CASE
WHEN EXISTS (
SELECT 1 FROM item_tags it
WHERE it.tag_id = t.id AND it.item_type = 'story'
) THEN "Yes"
ELSE "No"
END AS "Used in Archive?"
FROM tags t
""",
)

Expand Down Expand Up @@ -206,7 +214,7 @@ def update_tag_row(self, row: dict):
new_tag_id = sql_dict[0]["LAST_INSERT_ID()"]
# get all associated items from item_tags
items = self.sql.execute_dict(
f"""SELECT item_id, item_type
f"""SELECT item_id, item_type
FROM item_tags WHERE tag_id = {row['Original Tag ID']}"""
)

Expand Down
Loading