Skip to content

Commit

Permalink
Merge pull request #245 from giselles-ai/hotfix/build-error-of-calculate
Browse files Browse the repository at this point in the history
fix: Resolve type error in agent activity duration calculation
  • Loading branch information
gentamura authored Dec 17, 2024
2 parents 43eb896 + 1d2b58b commit 5cfe51a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/(main)/settings/team/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,19 @@ export async function getAgentActivities({
.orderBy(desc(agentActivities.startedAt))
.limit(limit);

const formattedActivities = activities.map((activity) => ({
...activity,
// Convert milliseconds to seconds and round to 2 decimal places
usedCharge: Math.ceil((activity.usedCharge / 1000) * 100) / 100,
}));
const formattedActivities = activities.map((activity) => {
const durationInSeconds = Number(activity.usedCharge) / 1000;

const validDuration = Number.isNaN(durationInSeconds)
? 0
: durationInSeconds;

return {
...activity,
// Convert milliseconds to seconds and round to 2 decimal places
usedCharge: Math.ceil(validDuration * 100) / 100,
};
});

return {
success: true,
Expand Down

0 comments on commit 5cfe51a

Please sign in to comment.