Skip to content

Commit

Permalink
clean up repo
Browse files Browse the repository at this point in the history
  • Loading branch information
maguowei committed Apr 15, 2024
1 parent f1ae04d commit b369dae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
18 changes: 15 additions & 3 deletions starred/githubgql.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
stargazerCount
forkCount
isPrivate
isArchived
isLocked
isFork
pushedAt
updatedAt
languages(first: 1, orderBy: {field: SIZE, direction: DESC}) {
Expand Down Expand Up @@ -45,15 +48,19 @@


class Repository:
def __init__(self, name, description, language, url, stargazer_count, is_private, topics):
def __init__(self, name, description, language, url, stargazer_count, is_private, topics, is_archived, is_locked, is_fork, pushed_at, updated_at):
self.name = name
self.description = description
self.language = language
self.url = url
self.stargazer_count = stargazer_count
self.is_private = is_private
self.topics = topics

self.is_archived = is_archived
self.is_locked = is_locked
self.is_fork = is_fork
self.pushed_at = pushed_at
self.updated_at = updated_at

class GitHubGQL:
API_URL = "https://api.github.com/graphql"
Expand All @@ -79,7 +86,12 @@ def get_user_starred_by_username(self, username: str, after: str = '', topic_sta
stargazer_count = repo['stargazerCount']
is_private = repo['isPrivate']
topics = [tag['topic']['name'] for tag in repo['repositoryTopics']['nodes'] if tag['topic']['stargazerCount'] > topic_stargazer_count_limit]
items.append(Repository(name, description, language, url, stargazer_count, is_private, topics))
is_archived = repo['isArchived']
is_locked = repo['isLocked']
is_fork = repo['isFork']
pushed_at = repo['pushedAt']
updated_at = repo['updatedAt']
items.append(Repository(name, description, language, url, stargazer_count, is_private, topics, is_archived, is_locked, is_fork, pushed_at, updated_at))

if has_next:
items.extend(self.get_user_starred_by_username(username, end_cursor, topic_stargazer_count_limit))
Expand Down
9 changes: 6 additions & 3 deletions starred/starred.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def starred(username, token, sort, topic, repository, filename, message, private
for category in s.topics or [DEFAULT_CATEGORY.lower()]:
if category not in repo_dict:
repo_dict[category] = []
repo_dict[category].append([s.name, s.url, description])
repo_dict[category].append([s.name, s.url, description, s.is_archived, s.is_locked, s.is_fork, s.pushed_at, s.updated_at])
else:
category = s.language or DEFAULT_CATEGORY

if category not in repo_dict:
repo_dict[category] = []
repo_dict[category].append([s.name, s.url, description])
repo_dict[category].append([s.name, s.url, description, s.is_archived, s.is_locked, s.is_fork, s.pushed_at, s.updated_at])

if sort:
repo_dict = OrderedDict(sorted(repo_dict.items(), key=lambda cate: cate[0]))
Expand All @@ -109,7 +109,10 @@ def starred(username, token, sort, topic, repository, filename, message, private
for category in repo_dict:
click.echo('## {} \n'.format(category.replace('#', '# #')))
for repo in repo_dict[category]:
data = u'- [{}]({}) - {}'.format(*repo)
data = u"""
- [{}]({}) - {}
- is_archived: {}, is_locked: {}, is_fork: {}, pushed_at: {}, updated_at: {}
""".format(*repo)
click.echo(data)
click.echo('')

Expand Down

0 comments on commit b369dae

Please sign in to comment.