Skip to content

Commit

Permalink
update summary
Browse files Browse the repository at this point in the history
  • Loading branch information
thewbuk authored and EiffelFly committed Nov 5, 2024
1 parent dc90012 commit b3196a0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 76 deletions.
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@instill-ai/toolkit",
"version": "0.110.0-rc.90",
"version": "0.110.0-rc.91",
"description": "Instill AI's frontend toolkit",
"repository": "https://github.com/instill-ai/design-system.git",
"bugs": "https://github.com/instill-ai/design-system/issues",
Expand Down
69 changes: 25 additions & 44 deletions packages/toolkit/src/lib/dashboard/getModelTriggersSummary.ts
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
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SelectOption } from "@instill-ai/design-system";

import {
DashboardAvailableTimeframe,
// getModelTriggersSummary,
getModelTriggersSummary,
getPipelineTriggersSummary,
getPreviousTimeframe,
getTimeInRFC3339Format,
Expand Down Expand Up @@ -155,10 +155,10 @@ export const DashboardActivityPageMainView = () => {
if (
triggeredPipelines.isError ||
pipelinesChart.isError ||
previousTriggeredPipelines.isError
// triggeredModels.isError ||
// modelsChart.isError ||
// previousTriggeredModels.isError
previousTriggeredPipelines.isError ||
triggeredModels.isError ||
modelsChart.isError ||
previousTriggeredModels.isError
) {
router.push("/404");
}
Expand All @@ -167,9 +167,9 @@ export const DashboardActivityPageMainView = () => {
triggeredPipelines.isError,
pipelinesChart.isError,
previousTriggeredPipelines.isError,
// triggeredModels.isError,
// modelsChart.isError,
// previousTriggeredModels.isError,
triggeredModels.isError,
modelsChart.isError,
previousTriggeredModels.isError,
]);

const pipelinesChartList = React.useMemo<PipelinesChart[]>(() => {
Expand Down Expand Up @@ -227,32 +227,12 @@ export const DashboardActivityPageMainView = () => {
return null;
}

const completedModel = modelsChart.data.modelTriggerCounts.find(
(r) => r.status === "STATUS_COMPLETED"
);

const erroredModel = modelsChart.data.modelTriggerCounts.find(
(r) => r.status === "STATUS_ERRORED"
);

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
}
};
return getModelTriggersSummary(modelsChart.data.modelTriggerCounts);
}, [
previousTriggeredModels.isSuccess,
modelsChart.isSuccess,
modelsChart.data?.modelTriggerCounts
modelsChart.data?.modelTriggerCounts,
selectedTimeOption // Add this to ensure refetch on date change
]);

return (
Expand Down

0 comments on commit b3196a0

Please sign in to comment.