Skip to content

refactor(meditations): remove randomSongUrl virtual field - #474

Merged
Ardnived merged 4 commits into
mainfrom
refactor/remove-random-song-url
Jun 8, 2026
Merged

Ardnived merged 4 commits into
mainfrom
refactor/remove-random-song-url

Conversation

@Ardnived

@Ardnived Ardnived commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Removes the randomSongUrl virtual field from Meditations — it ran a 2-query song lookup (count + random-page fetch) on every direct meditation read.
  • Clients now pick songs themselves via GET /api/songs?where[tags][in]=<songTag>&where[includeForMeditations][not_equals]=false&where[deletedAt][exists]=false, which returns the full tagged-song list. songTag is retained.
  • No migration — the field was virtual (no meditations table column).

Changes

  • src/collections/Meditations/Meditations.ts — remove the field, its import, and the defaultPopulate entry; reword the list-view comment.
  • src/collections/Meditations/hooks/randomSongUrl.ts — deleted.
  • src/payload-types.ts — regenerated (randomSongUrl gone from Meditation + MeditationsSelect).
  • tests/int/meditations.int.spec.ts — drop the 7 randomSongUrl tests; keep the two Songs includeForMeditations auto-set tests (relocated to their own describe block — see Notes); trim the dead randomSongUrl setup/assertions from the Admin list view select (#459) block (frames + tagAssignments coverage kept).
  • tests/COVERAGE.md / .claude/rules/collections.md — drop randomSongUrl; the defaultPopulate doc example now uses the live tagAssignments field.
  • .claude/hooks/prettier-format.mjs — exclude .md from the prettier hook (see Notes).

Test Results

  • Unit (pnpm test:unit): 366 passed
  • Integration (tests/int/meditations.int.spec.ts): 19 passed
  • Lint (pnpm lint): ✓ no errors
  • Full suite + build: deferred to CI (pnpm lint && pnpm test on the PR)

Notes for reviewer

  • Client coordination (out of repo scope): consumers reading randomSongUrl off the meditation response must move to the /api/songs tag filter before/alongside this change.
  • Preserved coverage: the issue said to delete the whole randomSongUrl virtual field describe block, but two of its tests cover the Songs autoSetIncludeForMeditationsOnCreate hook — the only coverage per tests/COVERAGE.md. They're kept, moved into a Songs includeForMeditations auto-set block.
  • Tooling fix (chore(hooks) commit): editing any .md made the prettier PostToolUse hook reformat the whole file (table/heading normalization → large unrelated diffs); markdown was never enforced by CI (lint is eslint . 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.
  • Possible follow-up (not done here): the relocated includeForMeditations block 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

Ardnived and others added 4 commits June 8, 2026 17:51
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]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-474 June 8, 2026 10:16 Destroyed
@railway-app

railway-app Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-474 environment in sahajcloud

Service Status Web Updated (UTC)
SahajCloud ✅ Success (View Logs) Web Jun 8, 2026 at 10:18 am

@Ardnived
Ardnived merged commit a0d2754 into main Jun 8, 2026
2 checks passed
@Ardnived
Ardnived deleted the refactor/remove-random-song-url branch June 8, 2026 10:37

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-474 — a8954d6e Deployed Jun 8, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(meditations): remove randomSongUrl virtual field

1 participant