Name the YouTube tables youtube_sources and youtube_items
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG4iASZnHb1yEM1JAASiWn
diff --git a/AGENTS.md b/AGENTS.md
index bdc9c5a..c1ac1d5 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -52,7 +52,7 @@ fly.toml — Fly config for the main demo and PR previews
- **User** has many Lists; identified by the login on the `Remote-User` header. Their settings page (`/settings`) connects a Google account (**GoogleAccount**, which keeps only the refresh token)
- **List** belongs to a User and has many Items and Axes, and one source (`source_kind` names a class in `Sources`). Each source renders its own sync dialog on the list page and applies what it posts: `Text`'s edits items by id, and a kind that fetches calls `Sync.call`. A fetching kind keeps its config in its own table keyed by `list_id` and its per-item details in a table keyed by `item_id`
-- Sources: `Text` (typed in, edited by id) and `YouTubePlaylist` (follows one of the owner's playlists through their Google account; `youtube_playlist_sources` by `list_id`, `youtube_playlist_items` by `item_id`)
+- Sources: `Text` (typed in, edited by id) and `YouTubePlaylist` (follows one of the owner's playlists through their Google account; `youtube_sources` by `list_id`, `youtube_items` by `item_id`)
- **Item** belongs to a List; removed items, and items missing from the latest sync, are archived (`archived_at`) and hidden everywhere
- **Axis** belongs to a List, has many Results
- **Result** belongs to an Axis, a winner (Item), and a loser (Item)
diff --git a/db/migrate/005_add_youtube.rb b/db/migrate/005_add_youtube.rb
index 6ab0207..818795a 100644
--- a/db/migrate/005_add_youtube.rb
+++ b/db/migrate/005_add_youtube.rb
@@ -14,14 +14,14 @@ Sequel.migration do
end
# The YouTubePlaylist source's config: which playlist a list follows.
- create_table(:youtube_playlist_sources) do
+ create_table(:youtube_sources) do
foreign_key :list_id, :lists, primary_key: true, on_delete: :cascade
String :playlist_id, null: false
end
# The video behind each item of a YouTubePlaylist list, which is how
# a sync recognizes the item again.
- create_table(:youtube_playlist_items) do
+ create_table(:youtube_items) do
foreign_key :item_id, :items, primary_key: true, on_delete: :cascade
String :video_id, null: false
end
diff --git a/lib/rank_king/sources/youtube_playlist.rb b/lib/rank_king/sources/youtube_playlist.rb
index 1e166ea..c91eb97 100644
--- a/lib/rank_king/sources/youtube_playlist.rb
+++ b/lib/rank_king/sources/youtube_playlist.rb
@@ -11,9 +11,9 @@ module RankKing
# Each sync fetches the whole playlist again.
class YouTubePlaylist
# Which playlist each list follows, keyed by list_id.
- TABLE = :youtube_playlist_sources
+ TABLE = :youtube_sources
# Which video each item is, keyed by item_id.
- ITEMS = :youtube_playlist_items
+ ITEMS = :youtube_items
#: () -> String
def self.title = "YouTube playlist"
diff --git a/test/test_youtube.rb b/test/test_youtube.rb
index 04ccacb..82cae5a 100644
--- a/test/test_youtube.rb
+++ b/test/test_youtube.rb
@@ -189,8 +189,8 @@ class TestYouTube < Minitest::Test
assert_equal "YouTubePlaylist", list.source_kind
refute_nil list.synced_at
assert_equal %w[First Third Fourth], names(list)
- assert_equal PLAYLIST, RankKing::DB[:youtube_playlist_sources].where(list_id: list.id).get(:playlist_id)
- assert_equal %w[v1 v3 v4], RankKing::DB[:youtube_playlist_items].order(:item_id).map(:video_id)
+ assert_equal PLAYLIST, RankKing::DB[:youtube_sources].where(list_id: list.id).get(:playlist_id)
+ assert_equal %w[v1 v3 v4], RankKing::DB[:youtube_items].order(:item_id).map(:video_id)
tokens = @google.calls.select { |_, url, _, _| url == RankKing::Google::TOKEN_URL }
assert_equal "refresh-the-code", tokens.last[2][:refresh_token]
@@ -263,8 +263,8 @@ class TestYouTube < Minitest::Test
csrf_post "/lists/#{list.id}/delete", {}, from: "/lists/#{list.id}/settings"
assert last_response.redirect?
- assert_equal 0, RankKing::DB[:youtube_playlist_sources].count
- assert_equal 0, RankKing::DB[:youtube_playlist_items].count
+ assert_equal 0, RankKing::DB[:youtube_sources].count
+ assert_equal 0, RankKing::DB[:youtube_items].count
end
private