Skip to content

Hand-written timeline range arrays still in two places after #3 dedup #5

@DennisAlund

Description

@DennisAlund

PR #3 deduplicated VALID_RANGES in src/api/analytics.ts and src/api/bundles.ts to derive from the canonical TIMELINE_RANGES in src/api/schemas.ts. Two more copies remain on main:

  • src/api/schemas.ts:206TimelineDataSchema defines range: z.enum(["24h", "7d", "30d", "90d", "1y", "all"]) inline. Same data, different file. The OpenAPI shape would diverge from TIMELINE_RANGES if either is edited in isolation.
  • src/services/admin-management.ts:11const VALID_RANGES: TimelineRange[] = ["24h", "7d", "30d", "90d", "1y", "all"] hand-written, used by isValidRange() and the default_range setting validator.

Both should derive from TIMELINE_RANGES so adding/removing a range is a one-place change.

Out-of-scope notes (for context, not changes wanted here):

  • Test files (__tests__/page/settings-page.test.ts:34, __tests__/service/admin-service.test.ts:119, __tests__/unit/mcp-range-wrapper.test.ts:55, __tests__/unit/api-schemas.test.ts:50) also hard-code the array. Boundary tests are arguably better with literal values; leaving them out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions