-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
71 lines (57 loc) · 2.39 KB
/
views.py
File metadata and controls
71 lines (57 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from flask import jsonify
from model import *
from collections import Counter
def get_top_languages(repo_soup: str) -> list:
elements = repo_soup.select("span[itemprop='programmingLanguage']")
texts = [element.text for element in elements]
return texts
def get_contributions_count(default_soup: str) -> int:
contributions_h2 = default_soup.find("h2", class_="f4 text-normal mb-2")
contributions_count = contributions_h2.get_text(strip=True).split()[0].replace(",", "")
return int(contributions_count)
def get_years_active(default_soup:str, username:str) -> int:
buttons = default_soup.find_all("a", class_="js-year-link")
count = 0
for button in buttons:
if f"/{username}?tab=overview" in button["href"]:
count += 1
return count
def analyze_languages(languages:list) -> str:
if len(languages) == 0:
return "Not enough languages to analyze"
else:
backend_count = 0
frontend_count = 0
for language in languages:
if language in backend_lang:
backend_count += 1
if language in frontend_lang:
frontend_count += 1
if len(languages) >= 3:
top_languages = Counter(languages).most_common(3)
else:
top_languages = Counter(languages).most_common(len(languages))
top_languages = [language[0] for language in top_languages]
if abs(backend_count - frontend_count)/ len(languages) <= 0.2:
return "🎩 Fullstack with " + ", ".join(top_languages)
else:
if backend_count > frontend_count:
return "🛠️ Backend with " + ", ".join(top_languages)
if frontend_count > backend_count:
return "🖥️ Frontend with " + ", ".join(top_languages)
def analyze_contributions(contributions: int) -> str:
if contributions <= 50:
return "👻 Ghost user"
elif contributions <= 100:
return "💤 Low activity"
elif contributions <= 300:
return "🏃🏻 Medium activity"
else:
return "🤸🏼♀️ High activity"
def analyze_years_active(years_active: int) -> str:
if years_active <= 1:
return f"🐥 Newbie for {years_active} year"
elif years_active <= 5:
return f"🌱 Junior for {years_active} years"
else:
return f"👨🎓 Senior for {years_active} years"