@mastra/pg 1.8.4-alpha.0 → 1.8.4-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5739,6 +5739,38 @@ var ExperimentsPG = class _ExperimentsPG extends ExperimentsStorage {
5739
5739
  );
5740
5740
  }
5741
5741
  }
5742
+ // --- Aggregation ---
5743
+ async getReviewSummary() {
5744
+ try {
5745
+ const tableName = getTableName2({ indexName: TABLE_EXPERIMENT_RESULTS, schemaName: getSchemaName2(this.#schema) });
5746
+ const rows = await this.#db.client.manyOrNone(
5747
+ `SELECT
5748
+ "experimentId",
5749
+ COUNT(*)::int as total,
5750
+ SUM(CASE WHEN status = 'needs-review' THEN 1 ELSE 0 END)::int as "needsReview",
5751
+ SUM(CASE WHEN status = 'reviewed' THEN 1 ELSE 0 END)::int as reviewed,
5752
+ SUM(CASE WHEN status = 'complete' THEN 1 ELSE 0 END)::int as complete
5753
+ FROM ${tableName}
5754
+ GROUP BY "experimentId"`
5755
+ );
5756
+ return (rows || []).map((row) => ({
5757
+ experimentId: row.experimentId,
5758
+ total: Number(row.total ?? 0),
5759
+ needsReview: Number(row.needsReview ?? 0),
5760
+ reviewed: Number(row.reviewed ?? 0),
5761
+ complete: Number(row.complete ?? 0)
5762
+ }));
5763
+ } catch (error) {
5764
+ throw new MastraError(
5765
+ {
5766
+ id: createStorageErrorId("PG", "GET_REVIEW_SUMMARY", "FAILED"),
5767
+ domain: ErrorDomain.STORAGE,
5768
+ category: ErrorCategory.THIRD_PARTY
5769
+ },
5770
+ error
5771
+ );
5772
+ }
5773
+ }
5742
5774
  // --- Clear ---
5743
5775
  async dangerouslyClearAll() {
5744
5776
  await this.#db.clearTable({ tableName: TABLE_EXPERIMENT_RESULTS });