Skip to content

getAllExperiments() loads every experiment (with relations) with no pagination #1390

Description

@RUKAYAT-CODER

Overview

AbTestingService.getAllExperiments() in src/ab-testing/ab-testing.service.ts runs experimentRepository.find({ relations: ['variants', 'metrics'], order: { createdAt: 'DESC' } }) with no take/skip. It eagerly loads every experiment along with all of their variants and metrics on a single request. As the number of experiments grows this becomes a large, slow query and a memory risk, and the endpoint that exposes it returns an unbounded payload.

Specifications

Features:

  • Listing experiments is paginated with a bounded, documented page size.
  • The endpoint accepts validated pagination parameters and returns a total count alongside the page.

Tasks:

  • Add pagination (skip/take, plus findAndCount for a total) to getAllExperiments() in src/ab-testing/ab-testing.service.ts, with a sane default and maximum page size.
  • Update the corresponding handler in src/ab-testing/ab-testing.controller.ts to accept and validate pagination query parameters and return the paginated shape.
  • Consider whether variants/metrics need to be eagerly joined for the list view or can be deferred to the detail endpoint.

Impacted Files:

  • src/ab-testing/ab-testing.service.ts
  • src/ab-testing/ab-testing.controller.ts

Acceptance Criteria

  • The list endpoint never returns more than the configured maximum number of experiments per request.
  • A default page size applies when no pagination parameters are provided; invalid values are rejected.
  • The response includes enough information to page through all experiments (e.g. total count / next page).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions