import { IMPOSSIBLE, VersionInfo } from '@start9labs/start-sdk'

/**
 * v1.0.0:6 — paginate history, no more 50-row caps.
 *
 * Two surfaces had hard 50-row caps that were invisible to the user:
 *
 *   - The clock-button "Exercise History" popup in the workout
 *     logging form: only ever showed the most recent 50 workouts
 *     containing that exercise. No way to see further back.
 *
 *   - The /main/workouts page: only ever rendered the most recent
 *     50 workouts. The only way to reach older ones was the date
 *     filter, but you had to know the date.
 *
 * Both now use server-side pagination + client-side infinite scroll
 * via IntersectionObserver. The first page renders identically to
 * before (instant paint, server-rendered for /main/workouts; first
 * 25 fetched on popup open). Subsequent pages auto-load when the
 * sentinel element scrolls into view. "End of history · N workouts"
 * shown once everything is loaded.
 *
 * Server queries use the `take: limit + 1` trick to detect hasMore
 * without a second COUNT() round-trip. The exercise-history query
 * was also rewritten to use Prisma's `setLogs.some` filter
 * (single SQL, hits the (userId, deletedAt, date) composite index)
 * instead of fetching all set logs and grouping in JS.
 *
 * No schema changes, no migration, no data movement. /data is
 * untouched.
 */
export const v_1_0_0_6 = VersionInfo.of({
  version: '1.0.0:6',
  releaseNotes: {
    en_US:
      'Paginate workout history. The clock-button "Exercise History" popup in the workout logger now scrolls infinitely to load older workouts. The /main/workouts page now does the same — scroll to the bottom and the next page auto-loads. No more invisible 50-row cap. No data migration; existing /data untouched.',
  },
  migrations: {
    up: async () => {},
    down: IMPOSSIBLE,
  },
})
