Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/reporters/github/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe("buildViewModel", () => {
hash: "new-query-1",
query: "SELECT 1",
formattedQuery: "SELECT 1",
optimization: { state: "no_improvement_found", cost: 10, indexesUsed: [] },
nudges: [], optimization: { state: "no_improvement_found", cost: 10, indexesUsed: [] },
},
],
}),
Expand Down Expand Up @@ -236,13 +236,13 @@ describe("buildViewModel", () => {
hash: "new-1",
query: "SELECT 1",
formattedQuery: "SELECT 1",
optimization: { state: "no_improvement_found", cost: 10, indexesUsed: [] },
nudges: [], optimization: { state: "no_improvement_found", cost: 10, indexesUsed: [] },
},
{
hash: "new-2",
query: "SELECT 2",
formattedQuery: "SELECT 2",
optimization: { state: "no_improvement_found", cost: 10, indexesUsed: [] },
nudges: [], optimization: { state: "no_improvement_found", cost: 10, indexesUsed: [] },
},
],
}),
Expand All @@ -269,7 +269,7 @@ describe("buildViewModel", () => {
hash: "new-1",
query: "SELECT 1",
formattedQuery: "SELECT 1",
optimization: { state: "no_improvement_found", cost: 10, indexesUsed: [] },
nudges: [], optimization: { state: "no_improvement_found", cost: 10, indexesUsed: [] },
},
],
}),
Expand Down
9 changes: 9 additions & 0 deletions src/reporters/site-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ export type CiOptimization =
costReductionPercentage: number;
indexRecommendations: CiIndexRecommendation[];
indexesUsed: string[];
explainPlan?: object;
optimizedExplainPlan?: object;
}
| {
state: "no_improvement_found";
cost: number;
indexesUsed: string[];
explainPlan?: object;
}
| {
state: "error";
Expand Down Expand Up @@ -129,6 +132,8 @@ function mapResultToQuery(result: QueryProcessResult): CiQueryPayload | null {
: 0,
indexRecommendations: result.indexRecommendations.map(mapIndexRecommendation),
indexesUsed: result.recommendation.existingIndexes,
explainPlan: result.recommendation.baseExplainPlan,
optimizedExplainPlan: result.recommendation.explainPlan,
},
};

Expand All @@ -142,6 +147,7 @@ function mapResultToQuery(result: QueryProcessResult): CiQueryPayload | null {
state: "no_improvement_found",
cost: result.cost,
indexesUsed: result.existingIndexes,
explainPlan: result.explainPlan,
},
};

Expand All @@ -155,6 +161,7 @@ function mapResultToQuery(result: QueryProcessResult): CiQueryPayload | null {
state: "no_improvement_found",
cost: 0,
indexesUsed: [],
explainPlan: result.explainPlan,
},
};

Expand All @@ -181,11 +188,13 @@ function mapResultToQuery(result: QueryProcessResult): CiQueryPayload | null {
state: "no_improvement_found",
cost: result.warning.baseCost,
indexesUsed: result.warning.optimization.existingIndexes,
explainPlan: result.warning.explainPlan,
}
: {
state: "no_improvement_found",
cost: result.warning.baseCost,
indexesUsed: [],
explainPlan: result.warning.explainPlan,
},
};

Expand Down
6 changes: 4 additions & 2 deletions src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export class Runner {
formattedQuery,
cost: out.baseCost,
existingIndexes: existingIndexesForQuery,
nudges, explainPlan: out.baseExplainPlan,
};
}
this.queryStats.optimized++;
Expand Down Expand Up @@ -398,6 +399,7 @@ export class Runner {
cost: out.baseCost,
existingIndexes: existingIndexesForQuery,
nudges,
explainPlan: out.baseExplainPlan,
};
}
} else if (out.kind === "zero_cost_plan") {
Expand Down Expand Up @@ -482,8 +484,8 @@ export type QueryProcessResult =
cost: number;
existingIndexes: string[];
nudges: Nudge[];
}
| {
explainPlan?: object;
} | {
kind: "error";
error: Error;
fingerprint: string;
Expand Down
Loading