@@ -96,7 +96,23 @@ def comment_frequency(self):
96
96
97
97
@property
98
98
def dependents_count (self ):
99
- raise NotImplementedError
99
+ # TODO: Take package manager dependency trees into account. If we decide
100
+ # to replace this, then find a solution for C/C++ as well.
101
+ parsed_url = urllib .parse .urlparse (self .url )
102
+ repo_name = parsed_url .path .strip ('/' )
103
+ dependents_url = (
104
+ f'https://github.com/search?q="{ repo_name } "&type=commits' )
105
+ content = b''
106
+ for i in range (FAIL_RETRIES ):
107
+ result = requests .get (dependents_url )
108
+ if result .status_code == 200 :
109
+ content = result .content
110
+ break
111
+ time .sleep (2 ** i )
112
+ match = DEPENDENTS_REGEX .match (content )
113
+ if not match :
114
+ return 0
115
+ return int (match .group (1 ).replace (b',' , b'' ))
100
116
101
117
102
118
class GitHubRepository (Repository ):
@@ -250,23 +266,6 @@ def comment_frequency(self):
250
266
since = issues_since_time ).totalCount
251
267
return round (comment_count / issue_count , 1 )
252
268
253
- @property
254
- def dependents_count (self ):
255
- repo_name = self .url .replace ('https://github.com/' , '' )
256
- dependents_url = (
257
- f'https://github.com/search?q="{ repo_name } "&type=commits' )
258
- content = b''
259
- for i in range (FAIL_RETRIES ):
260
- result = requests .get (dependents_url )
261
- if result .status_code == 200 :
262
- content = result .content
263
- break
264
- time .sleep (2 ** i )
265
- match = DEPENDENTS_REGEX .match (content )
266
- if not match :
267
- return 0
268
- return int (match .group (1 ).replace (b',' , b'' ))
269
-
270
269
271
270
class GitLabRepository (Repository ):
272
271
"""Source repository hosted on GitLab."""
@@ -277,11 +276,11 @@ def _date_from_string(date_string):
277
276
278
277
@property
279
278
def name (self ):
280
- return self ._repo .namespace [ ' name' ]
279
+ return self ._repo .name
281
280
282
281
@property
283
282
def url (self ):
284
- return self ._repo .namespace [ ' web_url' ]
283
+ return self ._repo .web_url
285
284
286
285
@property
287
286
def language (self ):
@@ -317,7 +316,7 @@ def contributor_count(self):
317
316
def org_count (self ):
318
317
# Not possible to calculate as this feature restricted to admins only.
319
318
# https://docs.gitlab.com/ee/api/users.html#user-memberships-admin-only
320
- return 0
319
+ return 1
321
320
322
321
@property
323
322
def commit_frequency (self ):
@@ -374,13 +373,6 @@ def comment_frequency(self):
374
373
pass
375
374
return round (comments_count / self .updated_issues_count , 1 )
376
375
377
- @property
378
- def dependents_count (self ):
379
- # TODO: Implement this once this feature is stable and available to
380
- # general users.
381
- # https://docs.gitlab.com/ee/api/dependencies.html
382
- return 0
383
-
384
376
385
377
def get_param_score (param , max_value , weight = 1 ):
386
378
"""Return paramater score given its current value, max value and
0 commit comments