Skip to content

feat(forms): derive key fields from per-field isKeyField flag#991

Merged
japsu merged 4 commits into
mainfrom
feature/key-fields-from-form-fields
Jul 7, 2026
Merged

feat(forms): derive key fields from per-field isKeyField flag#991
japsu merged 4 commits into
mainfrom
feature/key-fields-from-form-fields

Conversation

@japsu

@japsu japsu commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Key fields (shown in the response/program offer list) were stored as a
hardcoded list of slugs in Survey.key_fields. Rename that column to
Survey.cached_key_fields and denormalize it from a new per-field
isKeyField flag on Form.fields, editable via a checkbox in the form
field editor.

When form fields are saved, cached_key_fields is recomputed from the
language version being edited and the isKeyField flag is synced to the
other language versions. Program offer forms mark the title field as a
key field by default.

The GraphQL API field stays named keyFields; the cached/denormalized
nature is a backend implementation detail.

fixes #570

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Key fields (shown in the response/program offer list) were stored as a
hardcoded list of slugs in Survey.key_fields. Rename that column to
Survey.cached_key_fields and denormalize it from a new per-field
isKeyField flag on Form.fields, editable via a checkbox in the form
field editor.

When form fields are saved, cached_key_fields is recomputed from the
language version being edited and the isKeyField flag is synced to the
other language versions. Program offer forms mark the title field as a
key field by default.

The GraphQL API field stays named keyFields; the cached/denormalized
nature is a backend implementation detail.

fixes #570

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@japsu
japsu force-pushed the feature/key-fields-from-form-fields branch from bb15cce to 77a36d9 Compare July 7, 2026 19:45
Replace remaining manual cached_key_fields writes with refresh-based derivation and persist key-field intent in event form YAML via isKeyField flags.

Co-authored-by: GitHub Copilot <copilot@github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@japsu
japsu force-pushed the feature/key-fields-from-form-fields branch from da48795 to 03055ab Compare July 7, 2026 20:26
japsu added 2 commits July 7, 2026 23:33
Update Survey.refresh_cached_key_fields to refresh cached fields for existing current responses when cached_key_fields changes, and add regression coverage.
Wrap create_survey_language and update_form_fields mutations in transaction.atomic so response cache refresh can safely use select_for_update.
@japsu
japsu merged commit 2d6d90d into main Jul 7, 2026
11 checks passed
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.

As survey owner / program admin, I want to designate fields as key fields

1 participant