Skip to content

Commit

Permalink
Overall user downloads rate in top short summary #5
Browse files Browse the repository at this point in the history
  • Loading branch information
darsan-in committed Jul 11, 2024
1 parent 6f0fd50 commit 2371016
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions action/fetch-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,22 @@ function main() {
projects: groupedMeta,
totalProjects: ungroupedMeta.length,
totalCommits: 0,
overallDownloadCounts: getOverallDownloadCounts(ungroupedMeta),
};
(0, fs_1.writeFileSync)((0, path_1.join)(process.cwd(), "ghmeta.json"), JSON.stringify(localMeta));
return [2 /*return*/];
}
});
});
}
function getOverallDownloadCounts(ghMetas) {
var overallDownloadCounts = 0;
ghMetas.forEach(function (meta) {
var _a;
overallDownloadCounts += (_a = meta.downloadCount) !== null && _a !== void 0 ? _a : 0;
});
return overallDownloadCounts;
}
/* @ts-ignore */
function commitsCounter(urls) {
return __awaiter(this, void 0, void 0, function () {
Expand Down
11 changes: 11 additions & 0 deletions action/fetch-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ async function main(): Promise<void> {
projects: groupedMeta,
totalProjects: ungroupedMeta.length,
totalCommits: 0,
overallDownloadCounts: getOverallDownloadCounts(ungroupedMeta),
};

writeFileSync(
Expand All @@ -382,6 +383,16 @@ async function main(): Promise<void> {
);
}

function getOverallDownloadCounts(ghMetas: GithubRepoMeta[]): number {
let overallDownloadCounts: number = 0;

ghMetas.forEach((meta) => {
overallDownloadCounts += meta.downloadCount ?? 0;
});

return overallDownloadCounts;
}

/* @ts-ignore */
async function commitsCounter(urls: string[]): Promise<number> {
let overallCommits: number = 0;
Expand Down
3 changes: 3 additions & 0 deletions app/src/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export default function HomePage() {
<ShortMessage
totalProjects={localMeta.totalProjects ?? 0}
totalCommits={497}
overallDownloadCounts={
localMeta.overallDownloadCounts ?? 0
}
/>
</h1>

Expand Down
4 changes: 3 additions & 1 deletion app/src/components/ui-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import Spinner from "./spinner";
export const ShortMessage = ({
totalProjects,
totalCommits,
overallDownloadCounts,
}: {
totalProjects: number;
totalCommits: number;
overallDownloadCounts: number;
}) => {
return (
<>
{totalProjects ? (
`Over ${totalCommits}+ commits and ${totalProjects}+ projects completed`
`Over ${totalCommits}+ commits, ${overallDownloadCounts}+ NPM downloads and ${totalProjects}+ projects completed`
) : (
<Spinner size={20} />
)}
Expand Down
2 changes: 2 additions & 0 deletions app/src/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function fetchGHMeta(
},
totalProjects: localMetaWithoutAllCat.totalProjects,
totalCommits: localMetaWithoutAllCat.totalCommits,
overallDownloadCounts: localMetaWithoutAllCat.overallDownloadCounts,
};

setItemWithExpiration(localMetaKey, localMeta, expiryInHours);
Expand Down Expand Up @@ -104,6 +105,7 @@ export interface localMetaStructure {
projects: Record<string, GithubRepoMeta[]>;
totalProjects: number;
totalCommits: number;
overallDownloadCounts: number;
}

export function experienceDuration(dateString: string) {
Expand Down

0 comments on commit 2371016

Please sign in to comment.