diff --git a/app/context/StatsContext.tsx b/app/context/StatsContext.tsx index 0ceffb1..e5d5db9 100644 --- a/app/context/StatsContext.tsx +++ b/app/context/StatsContext.tsx @@ -5,6 +5,7 @@ import { calculateLanguageDistribution, calculateLicenseDistribution, calculateTopTopics, + calculateTotalArchived, calculateTotalForks, calculateTotalRepos, calculateTotalStars, @@ -26,6 +27,7 @@ type StatsContextProps = { totalGists: number; totalForks: number; totalTopics: number; + totalArchived: number; averageStarsPerRepo: number; starsPerRepo: Record; languages: Record; @@ -53,6 +55,7 @@ export const StatsProvider: React.FC<{ children: React.ReactNode }> = ({ const totalGists = calculateTotalRepos(gists); const totalStars = calculateTotalStars(repos); const totalForks = calculateTotalForks(repos); + const totalArchived = calculateTotalArchived(repos); const languages = calculateLanguageDistribution(repos); const licenses = calculateLicenseDistribution(repos); const topTopics = calculateTopTopics(repos); @@ -84,6 +87,7 @@ export const StatsProvider: React.FC<{ children: React.ReactNode }> = ({ latestUpdatedRepo, oldestRepo, updatePeriod, + totalArchived, }; // Provide the context value to the child components diff --git a/components/stats/Charts/StatTable.tsx b/components/stats/Charts/StatTable.tsx index b739f13..729e0a9 100644 --- a/components/stats/Charts/StatTable.tsx +++ b/components/stats/Charts/StatTable.tsx @@ -15,6 +15,7 @@ export default function StatTable({}: {}) { totalGists, averageStarsPerRepo, totalTopics, + totalArchived, } = statsContext ?? {}; const { user } = userContext; return ( @@ -71,6 +72,14 @@ export default function StatTable({}: {}) { Total Topics {totalTopics ?? 0} + + Total Archived Repositories + {totalArchived} + { return repos.filter((repo) => repo.fork).length; }; +/** + * Calculates the total number of archived repositories. + * + * @param {GitHubRepo[]} repos - Array of GitHub repositories. + * @returns {number} - Total number of archived repositories. + */ +export const calculateTotalArchived = (repos: GitHubRepo[]): number => { + return repos.filter((repo) => repo.archived).length; +} + /** * Calculates the distribution of programming languages across all repositories. * diff --git a/types.d.ts b/types.d.ts index 7f3f16c..39e9d4b 100644 --- a/types.d.ts +++ b/types.d.ts @@ -15,6 +15,7 @@ type GitHubRepo = { created_at: string; updated_at: string; pushed_at: string; + archived: boolean; topics: string[]; license_name: string; license_url: string;