Repository navigation
feat(seeds): re-enable lecture writes against the new Lectures + LectureClips shape - #313
Merged
Merged
Conversation
…ureClips shape Drops the throw-on-use guards introduced in #292 and rewires the wemeditate + storyblok importers to upsert a parent Lecture (keyed on `nirmalVidyaVimeoUrl`) plus a single full-video child LectureClip per unique vimeo_id. Rich-text content references the clip, not the parent, matching the post-#291 polymorphic move everywhere else. - `convertVimeo`: handles the actual nested `data.items[0].vimeo_id` shape from wemeditate source data; emits `lecture-clips` relationships; drops YouTube blocks with a logged warning (no NV YouTube ingest path) - `WeMeditateImporter.importLectures`: per-vimeo error isolation so a single NV API failure doesn't kill the 40-video batch — the failed id is just absent from `lectureClipMap` and the converter logs a missing-clip warning - `StoryblokImporter.upsertLecture`: same parent+clip pattern; returns the child clip id and the call site emits a `lecture-clips` relationship node - `Lectures.nirmalVidyaVimeoUrl`: promote the natural key from convention to schema with `unique: true, index: true` (new migration `20260426_105204`) Includes a unit-lane `convert-vimeo.spec.ts` for the pure converter and an integration `seeds-lectures.int.spec.ts` that mocks the NV API to verify the end-to-end parent+clip flow, skip-mode no-op, and per-vimeo error isolation. Closes #311 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #311.
Drops the throw-on-use guards introduced in PR #292 and rewires the wemeditate + storyblok importers to upsert a parent Lecture (keyed on
nirmalVidyaVimeoUrl) plus a single full-video child LectureClip per unique vimeo_id. Rich-text content references the clip, not the parent — matching the post-#291 polymorphic move (AppCards, ShowcaseBlock, RelationshipFeature, ContentIndexBlock,wm-app-config.postRealizationLecture) everywhere else.What changed
convertVimeo(seeds/lib/lexicalConverter.ts) — handles the actual nesteddata.items[0].vimeo_idshape from wemeditate source data (the original code looked atdata.vimeo_idwhich was always undefined for this dataset, so the legacy code never actually wrote any vimeo references). Emitslecture-clipsrelationships. Drops YouTube blocks with a logged warning — there is no Nirmala Vidya YouTube ingest path.ConversionContext.lectureMaprenamed tolectureClipMap(nowvimeo_id → clipId).WeMeditateImporter.importLectures(seeds/wemeditate/import.ts) — walks all page-content blocks, dedupes vimeo_ids (40 unique across 161 occurrences indata.json), upserts parent Lecture + child Clip per id. Per-vimeo error isolation: a single NV API failure (404, transient blip, missing duration) is contained — the failing id is just absent fromlectureClipMapand the converter logs a missing-clip warning. Preloads bothlectures(withmetadata+titleso skip-mode reads see the NV-fetched duration without a follow-up fetch) andlecture-clips.StoryblokImporter.upsertLecture(seeds/storyblok/import.ts) — mirrors the same parent + clip pattern. Returns the child clip id (not the lecture id) and the call site emits alecture-clipsrelationship node. Storyblok currently has 0 video stories in source, so this code path is unexercised but compiles and degrades safely.Lectures.nirmalVidyaVimeoUrl(src/collections/resources/Lectures.ts) — promoted the natural key from convention to schema withunique: true, index: true. New migration20260426_105204adds the unique index.Test infrastructure —
testData.createLecturenow generates a unique numeric vimeo id per call so multiple lectures created within one test file don't collide with the new unique constraint. The wemeditate / storyblok metadata files (expectedCounts.ts,setup-test-db.ts,check-db-stats.ts) now includelectures(40) +lecture-clips(40) for wemeditate.Tests added
@/lib/nirmalaVidyaApiper existing convention)The integration spec covers: parent + clip upsert with
endTime === metadata.duration, skip-mode no-op on re-run (NV hook does not re-fire), and per-vimeo error isolation when a single NV call rejects.Out of scope
SyncLectureMetadatajob)youtubeUrlfield + a YouTube metadata fetcher; track separately if editorial requires it)Test Results
pnpm tsc --noEmit): cleanpnpm build): ✓ SuccessTest plan
pnpm seed wemeditate(withNIRMALA_VIDYA_API_KEYset) and confirms ~40 new Lectures + ~40 LectureClips, each clip'sendTimematching its parent'smetadata.durationpnpm seed wemeditateis a flat-counts no-oprelationshipnode withrelationTo: 'lecture-clips'🤖 Generated with Claude Code