feat(web): real channel filter — multi-select of the user's channels
The free-text 'channel' filter was dead: it exact-matched SummaryRow.Channel,
which is just the provider ('youtube'), because videos never stored their source
channel. Now they do.
- migration 014: videos.channel_title (nullable; existing rows backfill on the
next discovery pass, pasted videos immediately).
- discovery (NewVideos) + paste (VideoByID) populate channel_title; UpsertVideo
persists it, preserving an existing title when an update arrives empty.
- store.DistinctChannels lists a user's channels (RLS-scoped); SummaryRow carries
ChannelTitle via the shared projection.
- Filter: single Channel -> Channels []string, matching on ChannelTitle; the feed
renders a multi-select of DistinctChannels (hidden until channels exist).
- migrate tests: 014 reversibility + fixed the relative-step counts in the 010/011
up/down tests (014 shifted the topology).
TDD throughout: channel persist + distinct, adapter channel wiring, multi-channel
filter match, handler channel filter, migration up/down.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -113,3 +113,29 @@ func TestNewestUnsummarizedVideoIDs(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, none, "limit 0 returns nothing")
|
||||
}
|
||||
|
||||
func TestUpsertVideoPersistsChannelAndDistinctChannels(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
s := newStore(t)
|
||||
resetDB(t, rawPool(t))
|
||||
|
||||
mk := func(pid, channel string) {
|
||||
v := ytVideo(userA, pid, pid)
|
||||
v.ChannelTitle = channel
|
||||
_, err := s.UpsertVideo(ctx, v)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
mk("aa11111aaaa", "Acme Talks")
|
||||
mk("bb22222bbbb", "Acme Talks") // same channel
|
||||
mk("cc33333cccc", "Zeta Channel")
|
||||
// userB's channel must not leak.
|
||||
vb := ytVideo(userB, "dd44444dddd", "x")
|
||||
vb.ChannelTitle = "Bravo Only"
|
||||
_, err := s.UpsertVideo(ctx, vb)
|
||||
require.NoError(t, err)
|
||||
|
||||
got, err := s.DistinctChannels(ctx, userA)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"Acme Talks", "Zeta Channel"}, got,
|
||||
"distinct, alphabetical, user-scoped (no Bravo Only)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user