-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 25 additions & 44 deletions
69
packages/toolkit/src/lib/dashboard/getModelTriggersSummary.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,28 @@ | ||
// import { | ||
// ModelTriggersStatusSummary, | ||
// ModelTriggerTableRecord, | ||
// } from "instill-sdk"; | ||
import { ModelTriggerCountRecord, ModelTriggersStatusSummary } from "instill-sdk"; | ||
|
||
// import { calculatePercentageDelta } from "./calculatePercentageDelta"; | ||
export function getModelTriggersSummary( | ||
modelTriggerCounts: ModelTriggerCountRecord[] | ||
): ModelTriggersStatusSummary { | ||
const completedModel = modelTriggerCounts.find( | ||
(r) => r.status === "STATUS_COMPLETED" | ||
); | ||
|
||
// export function getModelTriggersSummary( | ||
// models: ModelTriggerTableRecord[], | ||
// modelsPrevious: ModelTriggerTableRecord[], | ||
// ): ModelTriggersStatusSummary { | ||
// let modelCompleteAmount = 0; | ||
// let modelCompleteAmountPrevious = 0; | ||
// let modelErroredAmount = 0; | ||
// let modelErroredAmountPrevious = 0; | ||
const erroredModel = modelTriggerCounts.find( | ||
(r) => r.status === "STATUS_ERRORED" | ||
); | ||
|
||
// models.forEach((model) => { | ||
// modelCompleteAmount += Number(model.triggerCountCompleted); | ||
// modelErroredAmount += Number(model.triggerCountErrored); | ||
// }); | ||
|
||
// modelsPrevious.forEach((model) => { | ||
// modelCompleteAmountPrevious += Number(model.triggerCountCompleted); | ||
// modelErroredAmountPrevious += Number(model.triggerCountErrored); | ||
// }); | ||
|
||
// return { | ||
// completed: { | ||
// statusType: "STATUS_COMPLETED", | ||
// amount: modelCompleteAmount, | ||
// type: "model", | ||
// delta: calculatePercentageDelta( | ||
// modelCompleteAmountPrevious, | ||
// modelCompleteAmount, | ||
// ), | ||
// }, | ||
// errored: { | ||
// statusType: "STATUS_ERRORED", | ||
// amount: modelErroredAmount, | ||
// type: "model", | ||
// delta: calculatePercentageDelta( | ||
// modelErroredAmountPrevious, | ||
// modelErroredAmount, | ||
// ), | ||
// }, | ||
// }; | ||
// } | ||
return { | ||
completed: { | ||
statusType: "STATUS_COMPLETED" as const, | ||
type: "model" as const, | ||
amount: completedModel?.triggerCount || 0, | ||
delta: 0 | ||
}, | ||
errored: { | ||
statusType: "STATUS_ERRORED" as const, | ||
type: "model" as const, | ||
amount: erroredModel?.triggerCount || 0, | ||
delta: 0 | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters