Skip to content

test: guard dashboard query cost and host-less workshops - #3072

Merged
mroderick merged 2 commits into
masterfrom
3071-dashboard-query-specs
Nov 2, 2026
Merged

mroderick merged 2 commits into
masterfrom
3071-dashboard-query-specs

Conversation

@mroderick

Copy link
Copy Markdown
Collaborator

The host assertions from #3066 cannot catch a regression: dropping preload(workshop_host: :sponsor) leaves them green while restoring a per-card query on the dashboard. They also say nothing about workshops with no host. This PR closes both gaps in spec/queries/dashboard_query_spec.rb.

Summary

  • A query-count guard reads host for one and four dashboard cards and requires the same SQL statement count. Removing the preload now fails it.
  • A workshop with only non-host sponsors must resolve host to nil.
  • A workshop with no sponsor rows must appear in the result and resolve host to nil.

Review notes

Focus on both guards.

  • The query-count guard reads hosts the way the dashboard does. It counts non-cached sql.active_record events, excluding schema and transaction statements, and compares one workshop against four (the query caps at 10).
  • The host-less tests use workshop_no_sponsor because a physical workshop normally requires a host. Check that the fixtures match how real sponsor-less workshops are created.

I deliberately left the events request-level guards alone; they already cover the /events/upcoming render path.

The host assertions added in #3066 only checked the resolved sponsor, so
dropping the preload in DashboardQuery would restore a per-card query and
leave the suite green.

Count SQL statements while reading the attributes a dashboard card
renders for one and four cards, require a non-zero baseline, and pin the
two host-less cases: only non-host sponsors resolves to nil, and no
sponsor rows renders without breakage.

Closes #3071
@mroderick
mroderick force-pushed the 3071-dashboard-query-specs branch from 0578ea3 to 3fa3586 Compare November 2, 2026 12:20
@mroderick
mroderick marked this pull request as ready for review November 2, 2026 14:50
@mroderick
mroderick merged commit 65e87ef into master Nov 2, 2026
12 checks passed
@mroderick
mroderick deleted the 3071-dashboard-query-specs branch November 2, 2026 14:51
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.

1 participant