Skip to content

De-duplicate the parallel aggregateStats builders (mongo + sqlite) #123

@bharatsachya

Description

@bharatsachya

Type: simplification (DRY) · Difficulty: medium

packages/sqlite/src/aggregateStats.ts and packages/mongo/src/aggregateStats.ts build an identical StatsResponse and share logic, including the same magic Math.round(totalCost * 1_000_000) / 1_000_000 cost-rounding (sqlite:90, mongo:94). The activity.ts files in both adapters are similarly parallel (same slice(0, 500) snippet cap).

Do: extract the shared shaping (and a roundCostUsd/COST_PRECISION_FACTOR helper) into one place both adapters call, leaving each adapter to provide only its raw query results.

Done when: the StatsResponse shape and cost-rounding exist once; both adapters reuse them.

Metadata

Metadata

Assignees

No one assigned

    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