Skip to content
Merged
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
56 changes: 33 additions & 23 deletions get_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,50 @@

ORG_NAME = 'metakgp'

BLACKLISTED_LANGUAGES = {"Dockerfile", None, "Ruby", "CoffeeScript"}

def get_repositories(org_name):
url = f'https://api.github.com/orgs/{org_name}/repos'
repos = []
response = requests.get(url, params={'sort':'updated', 'per_page': 100, 'type': 'public'}) # we only have like 70 repos so don't need to handle pagination yet

repos = dict()

response = requests.get(url, params={'sort': 'updated', 'per_page': 100, 'type': 'public'})

if response.status_code != 200:
print(f"Error fetching repositories: {response.status_code} - {response.text}")
return repos

data = response.json()

for repo in data:
if repo['archived'] == False and repo['language'] not in BLACKLISTED_LANGUAGES:
repos.append({
'name': repo['name'],
'description': repo['description'],
'stars': repo['stargazers_count'],
'forks': repo['forks_count'],
'language': repo['language'],
'homepage': repo['homepage']
})

repos[repo.get('name')] = {
'stars': repo.get('stargazers_count', 0),
'forks': repo.get('forks_count', 0),
}

return repos

def save_to_json(data, filename):
with open(filename, 'w') as json_file:
json.dump(data, json_file, indent=4)
print(f"Data saved to {filename}")

def update_repo_data(fetched_repos, filename):
with open(filename, 'r') as f:
existing = json.load(f)

updated = []

for repo in existing:
name = repo.get('name')
fetched = fetched_repos.get(name)
if fetched:
repo['stars'] = fetched.get('stars', 0)
repo['forks'] = fetched.get('forks', 0)

updated.append(repo)

with open(filename, 'w') as f:
json.dump(updated, f, indent=4)
print(f"Wrote updated data to {filename}")


if __name__ == '__main__':
repositories = get_repositories(ORG_NAME)
save_to_json(repositories, "src/data/repo_data.json")
update_repo_data(repositories, "src/data/repo_data.json")

73 changes: 42 additions & 31 deletions src/components/GithubCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,62 @@ import { Link } from "react-router-dom";

const RepoCard = ({ repoData }: { repoData: REPO_DATA_TYPE }) => {
const repo_link = `https://github.com/metakgp/${repoData.name}`;
const stargazers_link = `https://github.com/metakgp/${repoData.name}/stargazers`
const forks_link = `https://github.com/metakgp/${repoData.name}/forks`

const Surround = repoData.homepage ? ({ children }: { children: React.ReactNode }) => (
<a href={repoData.homepage} target="_blank" rel="noreferrer" className="gh-card-container">
{children}
</a>
) : ({ children }: { children: React.ReactNode }) => (
<div className="gh-card-container">
{children}
</div>
);

return (
<Link to={repo_link} className="gh-card-container">
<Surround>
<div className="gh-card-header">
<span className="book-icon">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" className="octicon octicon-repo mr-1 color-fg-muted">
<span className="icon">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" className="octicon">
<path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path>
</svg>
</span>
<Link to={repo_link}>
<a href={repoData.homepage ? repoData.homepage : repo_link} target="_blank" rel="noreferrer">
<span className="gh-repo-name">{repoData.name}</span>
</Link>
</a>
<a href={repo_link} target="_blank" rel="noreferrer">
<span className="icon">
<svg width="25" height="25" viewBox="0 0 30 30" className="octicon" >
<path d="M15,3C8.373,3,3,8.373,3,15c0,5.623,3.872,10.328,9.092,11.63C12.036,26.468,12,26.28,12,26.047v-2.051 c-0.487,0-1.303,0-1.508,0c-0.821,0-1.551-0.353-1.905-1.009c-0.393-0.729-0.461-1.844-1.435-2.526 c-0.289-0.227-0.069-0.486,0.264-0.451c0.615,0.174,1.125,0.596,1.605,1.222c0.478,0.627,0.703,0.769,1.596,0.769 c0.433,0,1.081-0.025,1.691-0.121c0.328-0.833,0.895-1.6,1.588-1.962c-3.996-0.411-5.903-2.399-5.903-5.098 c0-1.162,0.495-2.286,1.336-3.233C9.053,10.647,8.706,8.73,9.435,8c1.798,0,2.885,1.166,3.146,1.481C13.477,9.174,14.461,9,15.495,9 c1.036,0,2.024,0.174,2.922,0.483C18.675,9.17,19.763,8,21.565,8c0.732,0.731,0.381,2.656,0.102,3.594 c0.836,0.945,1.328,2.066,1.328,3.226c0,2.697-1.904,4.684-5.894,5.097C18.199,20.49,19,22.1,19,23.313v2.734 c0,0.104-0.023,0.179-0.035,0.268C23.641,24.676,27,20.236,27,15C27,8.373,21.627,3,15,3z"></path>
</svg>
</span>
</a>
</div>
<div className="gh-card-body">
{repoData.description}
</div>
<div className="gh-card-footer">
<div className="gh-card-language-container">
<span className="gh-card-circle"></span>
<span className="gh-card-language">{repoData.language}</span>
{repoData.language.map(lang => <div className="gh-card-language-container">
<span className={`gh-card-circle gh-card-lang-${lang.toLowerCase()}`}></span>
<span className="gh-card-language">{lang}</span>
</div>)}
<div className="gh-card-star-container">
<span className="gh-card-star-icon">
<svg aria-label="stars" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" className="octicon octicon-star">
<path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path>
</svg>
</span>
{repoData.stars}
</div>
<div className="gh-card-forks-container">
<span className="gh-card-fork-icon">
<svg aria-label="forks" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" className="octicon octicon-repo-forked">
<path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path>
</svg>
</span>
{repoData.forks}
</div>
<Link to={stargazers_link}>
<div className="gh-card-star-container">
<span className="gh-card-star-icon">
<svg aria-label="stars" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" className="octicon octicon-star">
<path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path>
</svg>
</span>
{repoData.stars}
</div>
</Link>
<Link to={forks_link}>
<div className="gh-card-forks-container">
<span className="gh-card-fork-icon">
<svg aria-label="forks" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" className="octicon octicon-repo-forked">
<path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path>
</svg>
</span>
{repoData.forks}
</div>
</Link>
</div>
</Link>
</Surround>
)
}

Expand Down
Loading
Loading