Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/ContributionHeatmap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface ContributionData {

interface ContributionHeatmapProps {
data: ContributionData[];
contributionsLast30Days: number;
contributionsShown: number;
totalDaysShown: number;
subtitle?: string;
footerText?: string;
Expand All @@ -28,9 +28,9 @@ interface ContributionHeatmapProps {

const ContributionHeatmap: React.FC<ContributionHeatmapProps> = ({
data,
contributionsLast30Days,
contributionsShown,
totalDaysShown,
subtitle = 'network contribution(s) in the last 30 days',
subtitle = `network contribution(s) in the last ${totalDaysShown} day(s)`,
footerText,
emptyTitle = 'No contributions yet',
emptySubtitle = 'Activity will appear here once PRs are merged',
Expand All @@ -55,7 +55,7 @@ const ContributionHeatmap: React.FC<ContributionHeatmapProps> = ({
lineHeight: 1,
}}
>
{contributionsLast30Days.toLocaleString()}
{contributionsShown.toLocaleString()}
</Typography>
<Typography
variant="body2"
Expand Down
19 changes: 10 additions & 9 deletions src/components/miners/MinerActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ const MinerActivity: React.FC<MinerActivityProps> = ({
};

// Calculate contribution heatmap data
const { contributionData, contributionsLast30Days, totalDaysShown } =
const { contributionData, contributionsShown, totalDaysShown } =
useMemo(() => {
if (!prs || prs.length === 0) {
return {
contributionData: [],
contributionsLast30Days: 0,
contributionsShown: 0,
totalDaysShown: 0,
};
}
Expand All @@ -385,9 +385,6 @@ const MinerActivity: React.FC<MinerActivityProps> = ({
dataMap.set(format(subDays(today, i), 'yyyy-MM-dd'), 0);
}

let last30Count = 0;
const thirtyDaysAgo = subDays(today, 30);

prs.forEach((pr) => {
if (!pr.mergedAt) return;
const date = new Date(pr.mergedAt);
Expand All @@ -397,9 +394,13 @@ const MinerActivity: React.FC<MinerActivityProps> = ({
if (dataMap.has(dateStr)) {
dataMap.set(dateStr, (dataMap.get(dateStr) || 0) + 1);
}
if (date >= thirtyDaysAgo) last30Count++;
});

const shownCount = Array.from(dataMap.values()).reduce(
(total, count) => total + count,
0
);

const data = Array.from(dataMap.entries())
.map(([date, count]) => {
let level: 0 | 1 | 2 | 3 | 4 = 0;
Expand All @@ -413,7 +414,7 @@ const MinerActivity: React.FC<MinerActivityProps> = ({

return {
contributionData: data,
contributionsLast30Days: last30Count,
contributionsShown: shownCount,
totalDaysShown: daysToShow,
};
}, [prs]);
Expand Down Expand Up @@ -660,9 +661,9 @@ const MinerActivity: React.FC<MinerActivityProps> = ({
>
<ContributionHeatmap
data={contributionData}
contributionsLast30Days={contributionsLast30Days}
contributionsShown={contributionsShown}
totalDaysShown={totalDaysShown}
subtitle="contribution(s) in the last 30 days"
subtitle={`contribution(s) in the last ${totalDaysShown} day(s)`}
footerText="* Activity based on merged PRs in Gittensor-tracked repositories"
Comment on lines +664 to 667
bare
selectedDate={selectedDate}
Expand Down
Loading