Skip to content

Commit

Permalink
fix(networks): correct badge when maxYear undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonestla committed Nov 15, 2024
1 parent 5a6daa8 commit eee46f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions client/src/api/networks/network/communities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ const communityGetIds = (graph: Graph, community: number): Array<string> =>
const communityGetSize = (graph: Graph, community: number): number =>
graph.filterNodes((_, attr) => attr?.community === community).length

const communityGetMaxYear = (graph: Graph, community: number): number =>
Math.max(...communityGetAttribute(graph, community, "maxYear").map(Number))
const communityGetMaxYear = (graph: Graph, community: number): number => {
const maxYear = Math.max(...communityGetAttribute(graph, community, "maxYear").map(Number))
return Number.isFinite(maxYear) ? maxYear : undefined
}

const communityGetNodes = (graph: Graph, community: number): Array<{ id: string; weight: number; label: string }> => {
const ids = communityGetIds(graph, community)
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/networks/components/clusters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function ClusterItem({ currentTab, community }: ClusterItemArgs) {
{`${intl.formatMessage({ id: "networks.section.clusters.open-access" })}: ${community.oaPercent.toFixed(1)}%`}
</Badge>
<Badge size="sm" color="yellow-tournesol">
{`${intl.formatMessage({ id: "networks.section.clusters.last-activity" })}: ${community.maxYear}`}
{`${intl.formatMessage({ id: "networks.section.clusters.last-activity" })}: ${community?.maxYear || "N/A"}`}
</Badge>
<Badge size="sm" color="blue-cumulus">{`${intl.formatMessage(
{ id: "networks.section.clusters.citations" },
Expand Down

0 comments on commit eee46f1

Please sign in to comment.