Skip to content

Commit 2493570

Browse files
committed
chore: added new version of engine
1 parent 85ca1fd commit 2493570

3 files changed

Lines changed: 476 additions & 1 deletion

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ htmlcov/
88
build/
99
dist/
1010
poetry.lock
11-
coverage.xml
11+
coverage.xml
12+
13+
#tmp
14+
gen.py
15+
gen_data.py
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import Dict, Any
2+
3+
4+
class BusFactorMetric:
5+
def __init__(self, data: Dict[str, Any]) -> None:
6+
self.data = data["authors_statistics"]
7+
8+
def compute(self, threshold: float = 0.5) -> int:
9+
authors_stats = {}
10+
for author, item in self.data.items():
11+
authors_stats[author] = item.get("insertions", 0) + item.get("deletions", 0)
12+
13+
total = sum(authors_stats.values())
14+
acc = 0
15+
for _, lines in sorted(authors_stats.items(), key=lambda x: x[1], reverse=True):
16+
acc += lines
17+
if acc / total >= threshold:
18+
return len([a for a in authors_stats if authors_stats[a] >= lines])
19+
20+
return 777

0 commit comments

Comments
 (0)