Repository navigation
refactor(meditations): remove randomSongUrl virtual field - #474
Merged
Merged
Conversation
Drop the randomSongUrl virtual field and its afterRead hook from the Meditations collection. The hook ran a 2-query song lookup (count + random-page fetch) on every direct meditation read. Clients now select songs themselves via /api/songs filtered on the meditation's songTag, which returns the full tagged-song list for their own selection logic. Removes the field definition, the randomSongUrlAfterRead import, the defaultPopulate exclusion, and deletes the hook file. No migration: the field was virtual (no meditations table column). songTag is retained. Refs #458 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Remove the randomSongUrl virtual-field test suite from meditations.int.spec.ts. Preserve the two Songs includeForMeditations auto-set tests — the only coverage for autoSetIncludeForMeditationsOnCreate (per tests/COVERAGE.md) — by moving them into their own describe block. Trim the now-dead randomSongUrl setup and assertions from the Admin list view select (#459) block, keeping its frames + tagAssignments coverage. Refs #458 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… example - tests/COVERAGE.md: remove `randomSongUrl` virtual from the meditations row - .claude/rules/collections.md: swap the defaultPopulate canonical example from the removed randomSongUrl field to the live tagAssignments field Refs #458 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Prettier's markdown formatting (table padding, blank-lines-after-headings) can't be configured to match this repo's hand-maintained docs, so editing any .md file made prettier reformat the whole file — a large diff unrelated to the actual edit. Drop `md` from the prettier-format PostToolUse hook's extension allowlist; code files (js/ts/json/css/mjs) are still auto-formatted, docs are left as hand-authored. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
🚅 Deployed to the SahajCloud-pr-474 environment in sahajcloud
|
This branch was successfully deployed
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
randomSongUrlvirtual field from Meditations — it ran a 2-query song lookup (count + random-page fetch) on every direct meditation read.GET /api/songs?where[tags][in]=<songTag>&where[includeForMeditations][not_equals]=false&where[deletedAt][exists]=false, which returns the full tagged-song list.songTagis retained.meditationstable column).Changes
src/collections/Meditations/Meditations.ts— remove the field, its import, and thedefaultPopulateentry; reword the list-view comment.src/collections/Meditations/hooks/randomSongUrl.ts— deleted.src/payload-types.ts— regenerated (randomSongUrlgone fromMeditation+MeditationsSelect).tests/int/meditations.int.spec.ts— drop the 7randomSongUrltests; keep the two SongsincludeForMeditationsauto-set tests (relocated to their own describe block — see Notes); trim the deadrandomSongUrlsetup/assertions from theAdmin list view select (#459)block (frames + tagAssignments coverage kept).tests/COVERAGE.md/.claude/rules/collections.md— droprandomSongUrl; thedefaultPopulatedoc example now uses the livetagAssignmentsfield..claude/hooks/prettier-format.mjs— exclude.mdfrom the prettier hook (see Notes).Test Results
pnpm test:unit): 366 passedtests/int/meditations.int.spec.ts): 19 passedpnpm lint): ✓ no errorspnpm lint && pnpm teston the PR)Notes for reviewer
randomSongUrloff the meditation response must move to the/api/songstag filter before/alongside this change.randomSongUrl virtual fielddescribe block, but two of its tests cover the SongsautoSetIncludeForMeditationsOnCreatehook — the only coverage pertests/COVERAGE.md. They're kept, moved into aSongs includeForMeditations auto-setblock.chore(hooks)commit): editing any.mdmade the prettier PostToolUse hook reformat the whole file (table/heading normalization → large unrelated diffs); markdown was never enforced by CI (lintiseslint .only). The hook now skips.md; code files still format. Requested mid-implementation to keep doc edits clean — can split into its own PR if preferred.includeForMeditationsblock has a pre-existing cross-test order dependency (test 2 looks up the 'vocals' tag test 1 created). Left as-is to keep this PR scoped; stable since the integration lane runs sequentially.Closes #458
🤖 Generated with Claude Code