Skip to content

Add "Date Created" and "Number of Days Open" to Suggestions Admin - #2817

Open
VirginiaWu11 wants to merge 1 commit into
developfrom
2580-add-date-created-and-number-of-days-open-to-suggestions
Open

Add "Date Created" and "Number of Days Open" to Suggestions Admin#2817
VirginiaWu11 wants to merge 1 commit into
developfrom
2580-add-date-created-and-number-of-days-open-to-suggestions

Conversation

@VirginiaWu11

Copy link
Copy Markdown
Contributor
image image

Summary

Adds two read-only fields to the Suggestions Administration table and details modal so admins can see when a correction/suggestion was submitted and how long it's been open.

  • Date Created: the existing created_date, now exposed via the API (it was already in the DB but never selected for this view).
  • Number of Days Open: computed client-side on load — today − createdDate for OPEN statuses (New, Pending), closedDate − createdDate for CLOSED statuses (Incorrect, Confirmed), frozen once closed.

Why server changes were needed

The ticket assumed this was front-end only, but two gaps required backend work:

  • selectAll/selectById in suggestion-service.ts didn't select created_date for this view.
  • There was no closed_date column, so the CLOSED-status interval couldn't be computed at all.

Changes

  • Migration: new nullable closed_date timestamp column on suggestion.
  • Server: selectAll/selectById now return created_date/closed_date; update stamps closed_date when status moves to Incorrect/Confirmed (idempotent — re-saving a closed record doesn't reset the timestamp) and clears it when moved back to New/Pending. Added the fields to Suggestion/SuggestionPostFields types and the PUT validation schema (POST schema explicitly excludes them — they're server-derived, not client-supplied).
  • Client: added closedDate to the Suggestion and AdminSuggestion types; added a getDaysOpen/formatDate helper pair; inserted the two columns between Notes and Status in the table, and the two fields in the modal's Admin Notes section before Tipster details.

Notes

  • Historically-closed rows have no closed_date and will show n/a for days-open until an admin re-saves them with a closed status (not backfilled — accepted tradeoff).
  • Fixed a latent falsy-value bug in the shared DisplayText component's call site: a same-day suggestion has daysOpen === 0, which is falsy, so it's passed as a string to avoid being swallowed into "n/a".

@VirginiaWu11
VirginiaWu11 force-pushed the 2580-add-date-created-and-number-of-days-open-to-suggestions branch from 94c4060 to dc93f71 Compare June 23, 2026 02:27
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.

Add fields: "Date Created", "Number of Days Open"

1 participant