Repository navigation
Add each form's latest submission date to the form list API - #242
Conversation
GET /api/forms loads each form's newest completed session time as one subquery (withMax on form_sessions.is_completed). Sort and filter take only known values; anything else falls back to the default list instead of a 422 or 500. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PhilReinking
left a comment
There was a problem hiding this comment.
OK at 3a40567, CI green. One should, inline.
The 8 new tests fail on main and pass here. Odd sort and filter values (lists, empty, unknown column or direction, upper case) give the default list on MariaDB and SQLite. Newest first puts forms without submissions last on both. is_completed has been a datetime column since the first migration. The dashboard's three sort values still work, and the API docs list both params.
|
|
||
| ### Added | ||
|
|
||
| - The forms API (`GET /api/forms`) returns when each form last got a submission (`latest_submission_at`) and can sort by it, newest first. A link with an unknown filter or sort now shows the form list instead of an error. (#242) |
There was a problem hiding this comment.
Should: two things a reader of this line would want to know. On main, a dashboard link with an unknown filter or sort showed the empty state ("Start by creating a form"), not an error. And sort values that worked before, like published_at:desc or id:desc, now give the default order without an error. Maybe:
| - The forms API (`GET /api/forms`) returns when each form last got a submission (`latest_submission_at`) and can sort by it, newest first. A link with an unknown filter or sort now shows the form list instead of an error. (#242) | |
| - The forms API (`GET /api/forms`) returns when each form last got a submission (`latest_submission_at`) and can sort by it. Sorting now works only by `name`, `created_at`, `updated_at` or `latest_submission_at`, and any other filter or sort value gives the default list. Before, a dashboard link with an unknown filter or sort showed no forms at all. (#242) |
Forms with the same sort value, like forms without submissions under latest_submission_at, are now ordered newest first. The changelog names the sort values that are now ignored and what a bad dashboard link showed before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PhilReinking
left a comment
There was a problem hiding this comment.
OK at 2539a25, CI green. The changelog line is fixed.
The new test fails with the old Form.php and passes here, on MariaDB and SQLite. created_at desc as the second key does no harm when the first key is created_at too.
GET /api/formsnow returnslatest_submission_atfor each form: the time of its newest completed session, loaded as one subquery. The list can sort by it. An unknownfilterorsortvalue now gives the default list instead of a 422 or 500.Fixes BITS-251
latest_submission_atis ISO 8601 UTC likecreated_at(2026-10-03T09:30:00.000000Z), ornullwithout submissions.sort=latest_submission_at:desc: newest first, forms without submissions last, on MariaDB and SQLite.name,created_at,updated_atandlatest_submission_at, withascordesc. Before, any column name went intoORDER BY.completed_sessionsalso needs answers, so a form can show a date with 0 there.filterandsortthrough attributes, since the removed validation rule fed them before.Tested: full PHP suite on MariaDB and SQLite (in memory). The 10 new tests fail without the change. 30 forms: 91 queries before and after, so the new field adds none.
Not tested: in the browser. The dashboard uses the field in BITS-257.
Known gap: the 91 queries are older per-form queries (owner and two session counts). Not in this PR.
🤖 Generated with Claude Code