Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsartem committed Sep 27, 2024
1 parent 9f271c6 commit e159215
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cli/src/lib/chain/commitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,22 +747,27 @@ export async function getCommitmentsInfo(flags: CCFlags) {
}),
);

// group commitments by status
return Array.from(
commitmentsInfo
.reduce<
Map<CommitmentStatus | undefined, (typeof commitmentsInfo)[number][]>
>((acc, v) => {
const infos = acc.get(v.status) ?? [];
infos.push(v);
acc.set(v.status, infos);

acc.set(
v.status !== undefined && v.status in CommitmentStatus
? v.status
: undefined,
infos,
);

return acc;
}, new Map())
.entries(),
).map(([status, ccInfos]) => {
return {
status,
ccInfos,
};
return { status, ccInfos };
});
}

Expand Down

0 comments on commit e159215

Please sign in to comment.