Skip to content

Commit

Permalink
Add site to forum_category, now that groups are indirect.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Jan 29, 2024
1 parent 5768b04 commit 6948e89
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions migrations/20240112_create-initial-tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ CREATE TABLE forum_category (

CREATE TABLE forum_category_progress (
forum_category_id INTEGER PRIMARY KEY REFERENCES forum_category(forum_category_id),
site_slug TEXT NOT NULL REFERENCES site(site_slug),
thread_count INTEGER NOT NULL DEFAULT 0 CHECK (thread_count >= 0),
post_count INTEGER NOT NULL DEFAULT 0 CHECK (post_count >= 0),
last_thread_id INTEGER,
Expand Down
5 changes: 3 additions & 2 deletions queries/forum.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ DELETE FROM forum_group
WHERE site_slug = :site_slug;

-- :name add_forum_category :insert
INSERT INTO forum_category (forum_category_id, name, description)
VALUES (:category_id, :name, :description)
INSERT INTO forum_category (forum_category_id, site_slug, name, description)
VALUES (:category_id, :site_slug, :name, :description)
ON CONFLICT (forum_category_id)
DO UPDATE
SET
site_slug = :site_slug,
name = :name,
description = :description;
4 changes: 2 additions & 2 deletions yellowstone/job/index_forum_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def run(core: "BackupDispatcher", data: ForumCategoriesJob) -> None:

groups = forum_categories.get(site_slug, wikidot=core.wikidot)
for group in groups:
group_internal_id = core.database.add_forum_group(
core.database.add_forum_group(
site_slug=site_slug,
name=group.name,
description=group.description,
Expand All @@ -48,8 +48,8 @@ def run(core: "BackupDispatcher", data: ForumCategoriesJob) -> None:

# Upsert forum categories, associating internal forum group IDs
core.database.add_forum_category(
group_id=group_internal_id,
category_id=category.id,
site_slug=site_slug,
name=category.name,
description=category.description,
)
Expand Down

0 comments on commit 6948e89

Please sign in to comment.