MCPcopy Index your code
hub / github.com/EvanLi/Github-Ranking / ProcessorGQL

Class ProcessorGQL

source/process.py:56–147  ·  view source on GitHub ↗

Github GraphQL API v4 ref: https://docs.github.com/en/graphql use graphql to get data, limit 5000 points per hour check rate_limit with : curl -H "Authorization: bearer your-access-token" -X POST -d "{\"query\": \"{ rateLimit { limit cost remaining resetAt used }}\" }" https://a

Source from the content-addressed store, hash-verified

54
55
56class ProcessorGQL(object):
57 """
58 Github GraphQL API v4
59 ref: https://docs.github.com/en/graphql
60 use graphql to get data, limit 5000 points per hour
61 check rate_limit with :
62 curl -H "Authorization: bearer your-access-token" -X POST -d "{\"query\": \"{ rateLimit { limit cost remaining resetAt used }}\" }" https://api.github.com/graphql
63 """
64
65 def __init__(self):
66 self.gql_format = """query{
67 search(query: "%s", type: REPOSITORY, first:%d %s) {
68 pageInfo { endCursor }
69 edges {
70 node {
71 ...on Repository {
72 id
73 name
74 url
75 forkCount
76 stargazerCount
77 owner {
78 login
79 }
80 description
81 pushedAt
82 primaryLanguage {
83 name
84 }
85 openIssues: issues(states: OPEN) {
86 totalCount
87 }
88 }
89 }
90 }
91 }
92 }
93 """
94 self.bulk_size = 50
95 self.bulk_count = 2
96 self.gql_stars = self.gql_format % ("stars:>1000 sort:stars", self.bulk_size, "%s")
97 self.gql_forks = self.gql_format % ("forks:>1000 sort:forks", self.bulk_size, "%s")
98 self.gql_stars_lang = self.gql_format % ("language:%s stars:>0 sort:stars", self.bulk_size, "%s")
99
100 self.col = ['rank', 'item', 'repo_name', 'stars', 'forks', 'language', 'repo_url', 'username', 'issues',
101 'last_commit', 'description']
102
103 @staticmethod
104 def parse_gql_result(result):
105 res = []
106 for repo in result["data"]["search"]["edges"]:
107 repo_data = repo['node']
108 res.append({
109 'name': repo_data['name'],
110 'stargazers_count': repo_data['stargazerCount'],
111 'forks_count': repo_data['forkCount'],
112 'language': repo_data['primaryLanguage']['name'] if repo_data['primaryLanguage'] is not None else None,
113 'html_url': repo_data['url'],

Callers 1

run_by_gqlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected