Commit
·
c4f22f9
1
Parent(s):
23865ed
do rolling 52 weeks, small refactor, add official hf org
Browse files- src/components/Heatmap.tsx +3 -2
- src/components/OrganizationCard.tsx +1 -1
- src/pages/index.tsx +1 -2
- src/utils/calendar.ts +29 -15
src/components/Heatmap.tsx
CHANGED
@@ -42,10 +42,11 @@ const Heatmap: React.FC<HeatmapProps> = ({ data, color, providerName, fullName,
|
|
42 |
dark: ["#161b22", color],
|
43 |
light: ["#e0e0e0", color],
|
44 |
}}
|
|
|
45 |
hideTotalCount
|
46 |
renderBlock={(block, activity) => (
|
47 |
<Tooltip
|
48 |
-
title={`${activity.count}
|
49 |
arrow
|
50 |
>
|
51 |
{block}
|
@@ -57,4 +58,4 @@ const Heatmap: React.FC<HeatmapProps> = ({ data, color, providerName, fullName,
|
|
57 |
);
|
58 |
};
|
59 |
|
60 |
-
export default Heatmap;
|
|
|
42 |
dark: ["#161b22", color],
|
43 |
light: ["#e0e0e0", color],
|
44 |
}}
|
45 |
+
blockSize={11}
|
46 |
hideTotalCount
|
47 |
renderBlock={(block, activity) => (
|
48 |
<Tooltip
|
49 |
+
title={`${activity.count} new repos on ${activity.date}`}
|
50 |
arrow
|
51 |
>
|
52 |
{block}
|
|
|
58 |
);
|
59 |
};
|
60 |
|
61 |
+
export default Heatmap;
|
src/components/OrganizationCard.tsx
CHANGED
@@ -203,7 +203,7 @@ const OrganizationCard: React.FC<OrganizationCardProps> = ({
|
|
203 |
|
204 |
{/* Releases Past Year */}
|
205 |
<div className="text-xs text-muted-foreground italic">
|
206 |
-
<span className="font-bold text-foreground">{totalCount
|
207 |
</div>
|
208 |
</div>
|
209 |
</div>
|
|
|
203 |
|
204 |
{/* Releases Past Year */}
|
205 |
<div className="text-xs text-muted-foreground italic">
|
206 |
+
<span className="font-bold text-foreground">{totalCount}</span> new repos in the last year
|
207 |
</div>
|
208 |
</div>
|
209 |
</div>
|
src/pages/index.tsx
CHANGED
@@ -11,7 +11,6 @@ import { fetchAllProvidersData, fetchAllAuthorsData } from "../utils/authors";
|
|
11 |
import UserSearchDialog from "../components/UserSearchDialog";
|
12 |
import ProviderSummary from "../components/ProviderSummary";
|
13 |
import OrganizationCard from "../components/OrganizationCard";
|
14 |
-
import { getRankingBadge } from "../utils/ranking";
|
15 |
|
16 |
const PROVIDERS: ProviderInfo[] = [
|
17 |
{ color: "#ff7000", authors: ["mistralai"] },
|
@@ -28,7 +27,7 @@ const PROVIDERS: ProviderInfo[] = [
|
|
28 |
{ color: "#4C6EE6", authors: ["CohereLabs"] },
|
29 |
{ color: "#4C6EE6", authors: ["ibm-granite"] },
|
30 |
{ color: "#A020F0", authors: ["stabilityai"] },
|
31 |
-
{ color: "#FEC912", authors: ["HuggingFaceTB","HuggingFaceH4", "HuggingFaceM4", "HuggingFaceFW", "HuggingFaceFV","open-r1","parler-tts","nanotron","lerobot","distilbert"] },
|
32 |
];
|
33 |
|
34 |
export async function getStaticProps() {
|
|
|
11 |
import UserSearchDialog from "../components/UserSearchDialog";
|
12 |
import ProviderSummary from "../components/ProviderSummary";
|
13 |
import OrganizationCard from "../components/OrganizationCard";
|
|
|
14 |
|
15 |
const PROVIDERS: ProviderInfo[] = [
|
16 |
{ color: "#ff7000", authors: ["mistralai"] },
|
|
|
27 |
{ color: "#4C6EE6", authors: ["CohereLabs"] },
|
28 |
{ color: "#4C6EE6", authors: ["ibm-granite"] },
|
29 |
{ color: "#A020F0", authors: ["stabilityai"] },
|
30 |
+
{ color: "#FEC912", authors: ["huggingface","HuggingFaceTB","HuggingFaceH4", "HuggingFaceM4", "HuggingFaceFW", "HuggingFaceFV","open-r1","parler-tts","nanotron","lerobot","distilbert"] },
|
31 |
];
|
32 |
|
33 |
export async function getStaticProps() {
|
src/utils/calendar.ts
CHANGED
@@ -14,9 +14,16 @@ export const generateCalendarData = (
|
|
14 |
);
|
15 |
|
16 |
const today = new Date();
|
|
|
|
|
|
|
|
|
|
|
17 |
const startDate = new Date(today);
|
18 |
-
startDate.
|
19 |
-
|
|
|
|
|
20 |
|
21 |
// create a map to store counts for each provider and date
|
22 |
const countMap: Record<string, Record<string, number>> = {};
|
@@ -50,22 +57,29 @@ export const generateCalendarData = (
|
|
50 |
]),
|
51 |
);
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
// assign levels based on count relative to average
|
54 |
Object.entries(data).forEach(([provider, days]) => {
|
55 |
const avgCount = avgCounts[provider];
|
56 |
-
|
57 |
-
day.level =
|
58 |
-
|
59 |
-
? 0
|
60 |
-
: day.count <= avgCount * 0.5
|
61 |
-
? 1
|
62 |
-
: day.count <= avgCount
|
63 |
-
? 2
|
64 |
-
: day.count <= avgCount * 1.5
|
65 |
-
? 3
|
66 |
-
: 4;
|
67 |
-
});
|
68 |
});
|
69 |
|
70 |
return data;
|
71 |
-
};
|
|
|
14 |
);
|
15 |
|
16 |
const today = new Date();
|
17 |
+
|
18 |
+
// Calculate the first date to display GitHub-style:
|
19 |
+
// 1. Go back 52 weeks (364 days) from today so we cover the last year.
|
20 |
+
// 2. Shift further back to the previous Sunday (if necessary) so that
|
21 |
+
// the first column of the heatmap always begins on a Sunday.
|
22 |
const startDate = new Date(today);
|
23 |
+
startDate.setDate(startDate.getDate() - 364);
|
24 |
+
|
25 |
+
const dayOfWeek = startDate.getDay();
|
26 |
+
startDate.setDate(startDate.getDate() - dayOfWeek);
|
27 |
|
28 |
// create a map to store counts for each provider and date
|
29 |
const countMap: Record<string, Record<string, number>> = {};
|
|
|
57 |
]),
|
58 |
);
|
59 |
|
60 |
+
const calculateLevel = (count: number, avgCount: number): number => {
|
61 |
+
if (count === 0) {
|
62 |
+
return 0;
|
63 |
+
}
|
64 |
+
if (count <= avgCount * 0.5) {
|
65 |
+
return 1;
|
66 |
+
}
|
67 |
+
if (count <= avgCount) {
|
68 |
+
return 2;
|
69 |
+
}
|
70 |
+
if (count <= avgCount * 1.5) {
|
71 |
+
return 3;
|
72 |
+
}
|
73 |
+
return 4;
|
74 |
+
};
|
75 |
+
|
76 |
// assign levels based on count relative to average
|
77 |
Object.entries(data).forEach(([provider, days]) => {
|
78 |
const avgCount = avgCounts[provider];
|
79 |
+
for (const day of days) {
|
80 |
+
day.level = calculateLevel(day.count, avgCount);
|
81 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
});
|
83 |
|
84 |
return data;
|
85 |
+
};
|