Skip to content

Commit

Permalink
Make sure cost is shown even when equaling 0
Browse files Browse the repository at this point in the history
Fixes #634
  • Loading branch information
pgiraud committed Oct 9, 2024
1 parent 26825f0 commit 6d828d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/PlanNodeDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ watch(activeTab, () => {
}"
></FontAwesomeIcon>
</div>
<div v-if="node[NodeProp.EXCLUSIVE_COST]">
<div v-if="!_.isUndefined(node[NodeProp.EXCLUSIVE_COST])">
<FontAwesomeIcon
fixed-width
:icon="faDollarSign"
Expand Down
16 changes: 16 additions & 0 deletions src/services/__tests__/17-cost-0.00.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { PlanService } from "@/services/plan-service"
import type { IPlan, IPlanContent } from "@/interfaces"

describe("PlanService", () => {
test("Computes exclusive cost correctly", () => {
const planService = new PlanService()

// tslint:disable:max-line-length
const source = `Seq Scan on atividade_economica ae (cost=0.00..0.00 rows=1 width=36)`

const r = planService.fromSource(source) as IPlanContent
const plan: IPlan = planService.createPlan("", r, "")
const root = plan.content.Plan
root && expect(root["*Cost (exclusive)"]).toBe(0)
})
})
2 changes: 1 addition & 1 deletion src/services/plan-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class PlanService {
node[NodeProp.EXCLUSIVE_DURATION] = duration > 0 ? duration : 0
}

if (node[NodeProp.TOTAL_COST]) {
if (!_.isUndefined(node[NodeProp.TOTAL_COST])) {
node[NodeProp.EXCLUSIVE_COST] = node[NodeProp.TOTAL_COST]
}

Expand Down

0 comments on commit 6d828d6

Please sign in to comment.