| CO-1 |
BE: schema, enum, entity and every is_hide reader |
new db/changelog/sql/202610300001-video-visibility.sql, enums/VideoVisibility.java; entity/VideoSource.java:53-55, entity/VideoImportJob.java (+ visibility), repo/VideoSourceRepository.java:31,36,45,54-71, repo/VideoCollectionItemRepository.java:17,21, repo/WatchHistoryRepository.java:52,86,94, service/impl/StreamVideoServiceImpl.java:90,100, service/impl/HlsPlaybackServiceImpl.java:44, service/impl/VideoCollectionServiceImpl.java:209, service/impl/VideoReactionServiceImpl.java:59, service/impl/AdminVideoServiceImpl.java:109-115,211, service/impl/VideoStorageServiceImpl.java:264-266, dto/admin/AdminVideoDto.java:24; tests: new repo/VideoVisibilityMigrationTest (pattern VideoSourceFeedIndexMigrationTest), StreamVideoServiceImplTest, AdminVideoServiceImplTest, AdminControllerTest, VideoCollectionServiceImplTest, VideoReactionServiceImplTest, HlsPlaybackServiceImplTest, VideoSourceDefaultsTest, WatchHistoryServiceImplTest, VideoViewServiceImplTest, JsonContractTest + json-contract/dto-admin-video.json |
(1) Changeset = spec SQL: header --liquibase formatted sql, one --changeset nguyenhuuca:202610300001-video-visibility, backfill, 2 CHECKs, recreated idx_video_sources_feed, new idx_video_import_jobs_drive_file_id, is_hide dropped, --rollback lines; the migration test asserts each of them in the file text (Rule 1, Rule 4, FR-1). (2) VideoVisibility { FEED, COLLECTION_ONLY, HIDDEN }; VideoSource.visibility and VideoImportJob.visibility are @Enumerated(STRING) @Column(length=20, nullable=false) @Builder.Default FEED (FR-2). (3) Feed query findAllByVisibilityAndStatusOrderByPriorityDescCreatedAtDesc(FEED, PUBLISHED) (Rule 2, FR-3). (4) Every other reader uses the playable rule: VISIBLE = v.visibility <> 'HIDDEN' AND v.status = 'PUBLISHED', existsByIdAndVisibilityNotAndStatus(id, HIDDEN, PUBLISHED), incrementViewCount / WatchHistoryRepository visibility <> 'HIDDEN', getVideoById and findPlaylist != HIDDEN (Rule 3, FR-4). Each service test gets a COLLECTION_ONLY case that passes and a HIDDEN case that is rejected. (5) upsertDriveSource INSERT writes 'FEED' (its param comes in CO-3); ON CONFLICT does not touch visibility (Rule 7). (6) updateHidden(id, hidden) maps to HIDDEN / FEED and still invalidates FeedCache; AdminVideoDto gets visibility and a derived hidden (FR-6). (7) grep -rn "is_hide\|isHide\|IsHide\|setHide" api/src/main returns only the migration files. (8) mvn verify green, coverage ≥ 90%. (9) Local run: restore a prod-like dump into local Postgres, ./startLocal.sh, Liquibase applies the changeset, hidden rows read HIDDEN, the app boots and /video-stream/list answers; then running the file's --rollback statements with psql restores is_hide and the old index, and deleting the databasechangelog row lets the next boot apply it again (memory: green CI ≠ app boots) |
~120 + ~260 |
| CO-2 |
BE: admin visibility endpoint takes {visibility} |
web/AdminController.java:111-122, service/AdminVideoService.java, service/impl/AdminVideoServiceImpl.java (updateVisibility); tests AdminControllerTest, AdminVideoServiceImplTest |
(1) PATCH /admin/videos/{id}/visibility accepts {visibility} with each of the 3 values and the legacy {hidden} (FR-5, EC-1). (2) 400 for a null body, neither field, both fields (EC-2) and an unknown value, with the spec messages; the service is not called. (3) Unknown id → 400 Video not found: {id} (unchanged). (4) Every call saves and invalidates FeedCache, including the same value again (Rule 9, EC-7). (5) Role guard and @AuditLog("updateVideoVisibility") unchanged |
~50 + ~110 |
| CO-3 |
BE: import visibility and row creation |
dto/admin/CreateVideoImportRequest.java (+ visibility), dto/admin/VideoImportJobDto.java (+ visibility), service/VideoImportService.java, service/impl/VideoImportServiceImpl.java:60-126,242- (create, createResolved, createJob, toDto), service/impl/VideoSuggestionServiceImpl.java:327-330, service/impl/VideoStorageServiceImpl.java:59-103,248-292 (inject VideoImportJobRepository with an @Autowired setter like the others), repo/VideoSourceRepository.java:58-71 (+ visibility param); tests VideoImportServiceImplTest, VideoStorageServiceImplTest:207-275,500-545, DriveSyncServiceImplTest:289-327, VideoSuggestionServiceImplTest, AdminVideoImportControllerTest, JsonContractTest:92, BeanConstructorTest |
(1) visibility null → FEED; COLLECTION_ONLY stored on every job of the request; HIDDEN or unknown → 400 subCode 4104 INVALID_VISIBILITY, no job saved (Rule 5, EC-3, FR-7). (2) createResolved takes a visibility; suggestion approval passes FEED (EC-10). (3) Retry keeps the job's visibility: retryIfFinal does not touch the column, and a test asserts it (Rule 8). (4) VideoImportJobDto.visibility is set by toDto. (5) saveInfo sets the builder's visibility from the latest job for the Drive file, new repository method findFirstByDriveFileIdOrderByIdDesc(fileId) (several jobs can share a file after a re-import; the existing findFirstByDriveFileId at VideoImportJobRepository.java:29 has no order), else FEED; upsertInfo passes the same value to upsertDriveSource; an existing row is unchanged (Rules 6–7, EC-4, FR-8). (6) BeanConstructorTest green |
~90 + ~220 |
| CO-4 |
FE: admin three-state control, badge, Add to collection |
webapp/src/api/admin.js:18, webapp/src/hooks/useAdmin.js:61-67, webapp/src/components/admin/AdminVideoTable.jsx:167,176,198-220,248-284, webapp/src/styles/index.css (badge), webapp/src/i18n/locales/{en,vi}/admin.json:57,116-119; tests AdminVideoTable.test.jsx, api/__tests__/admin.test.js, i18n/__tests__/parity.test.js |
(1) updateVideoVisibility(id, visibility) sends {visibility}; the hook invalidates ['admin','videos'] (FR-5). (2) The hidden checkbox becomes a 3-option control (Feed / Collection only / Hidden) with the existing busy state and SaveIndicator; the tooltip says collection-only is not private (FR-9, spec Security). (3) Row class is-hidden follows visibility === 'HIDDEN'; a COLLECTION_ONLY badge is shown. (4) A row action "Add to collection" opens AddToCollectionModal with { id } (it only reads video.id). (5) New EN/VI keys pass the parity test |
~150 + ~160 |
| CO-5 |
FE: import "Collection only" option |
webapp/src/api/admin.js:44-45, webapp/src/components/admin/ImportForm.jsx:47-71,98-110, webapp/src/components/admin/ImportTable.jsx:99, webapp/src/i18n/locales/{en,vi}/admin.json; tests AdminImportPanel.test.jsx (no ImportForm/ImportTable tests exist) |
(1) A "Collection only" checkbox, off by default; checked → the body has visibility: "COLLECTION_ONLY", unchecked → no visibility field (FR-10). (2) ImportTable shows a badge on COLLECTION_ONLY jobs. (3) The 400/4104 error shows through the existing error path. (4) EN/VI parity |
~40 + ~90 |
| CO-6 |
FE: deep-link fallback in the feed |
webapp/src/api/videos.js:3-6 (+ get(id)), webapp/src/components/video/VideoFeed.jsx:6-45, webapp/src/components/video/VideoSwiper.jsx:241 (+ searchVideos prop); tests PublicFeed.resume.test.jsx, AppShell.deeplink.test.jsx, new components/video/__tests__/feedSurfaces.test.jsx (SearchModal, ExploreView, AddVideosModal) |
(1) Id found in the feed → unchanged behaviour (existing tests pass). (2) Id not found → GET /video-stream/{id} once (query key ['video', id]); on 200 the video is inserted at index 0, the swiper starts there and deepLinkStartAt resumes it (FR-11, EC-5). (3) On error → feed at initialIndex ?? 0, nothing inserted, no message (EC-6). (4) onDeepLinkResolved() is called in all three outcomes, so AppShell clears deepLinkId (today a missing id is never resolved). (5) The inserted video is not added to the cached ['videos', category] list. (6) Feed search keeps using the feed list without the inserted video: VideoFeed passes the pre-insert list to VideoSwiper as a separate searchVideos prop, which VideoSwiper.jsx:241 hands to SearchModal (today it passes the slide list). SearchModal returns indexes into the list it gets (SearchModal.jsx:86,92,109), so VideoSwiper must map by id both ways: onSelect(i) → videos.findIndex(v => v.id === searchVideos[i].id) before setIndex (VideoSwiper.jsx:244-248), and currentIndex = position of videos[index].id in searchVideos, or -1 on the inserted slide (:242). Tests: after a deep-link insert, (a) search does not list the inserted video, (b) selecting the second feed result shows that video's slide, (c) no row is marked current while the inserted slide plays. (8) Implementation notes from plan review: while deepLinkId is set, not in the feed and the ['video', id] query is pending, render LoadingState instead of the swiper (VideoSwiper.jsx:12 reads initialIndex once); the inserted video and a resolved flag live in PublicFeed state, because AppShell clears deepLinkId right after onDeepLinkResolved, and the callback fires exactly once per outcome (test); VideoSwiper defaults searchVideos = videos so LibraryView.jsx:206 and the existing swiper tests are unchanged. Known limitation: the slide counter (VideoSwiper.jsx:216) shows N+1 while the inserted slide exists. (7) Surfaces that read the feed list do not show a video absent from it: a test renders SearchModal, ExploreView and AddVideosModal with a mocked useVideos list and asserts each one shows only the list items (no other source of videos); together with the CO-1 feed-query test this covers the spec AC "feed search, Explore hero and Add videos picker do not show COLLECTION_ONLY" |
~60 + ~130 |
| CO-7 |
Land: deploy, prod smoke, docs |
docs/sequence/sequence-collection-only-videos.md (Status As-built), docs/tracking.md, TASKS.md, session.txt |
(1) Before the backend push: pg_dump backup of prod. (2) Push 1 = CO-1..CO-3 (owner approves the push); from push 1 until push 2 is live, no visibility edits on the Admin page, because the old page sends {hidden:false} and would reset a COLLECTION_ONLY row to FEED (EC-1); funnyapp-ci green; prod log shows the changeset applied and the app started. (3) Push 2 = CO-4..CO-6; Deploy Frontend green. (4) Prod smoke: set a video to Collection only → gone from the feed within 30 s, still plays in a collection and via ?v=; import one URL with Collection only → never appears in the feed; Hidden still hides everywhere. (5) Diagrams marked As-built, tracking ✅ |
docs only |
| CO-F1 |
Follow-up: remove the legacy {hidden} body and the hidden DTO field |
web/AdminController.java, dto/admin/AdminVideoDto.java, json-contract/dto-admin-video.json, tests |
After CO-7 push 2 is live: legacy body → 400, hidden gone from the DTO and the contract JSON (FR-13) |
~-30 + ~40 |