Spaces:
Sleeping
Sleeping
Update github_analytics/home.py
Browse files- github_analytics/home.py +60 -0
github_analytics/home.py
CHANGED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from github_analytics.fetch_data import fetch_user_data
|
3 |
+
from github_analytics.display_user_info import display_user_info
|
4 |
+
from github_analytics.pie_chart import create_pie_chart
|
5 |
+
from github_analytics.line_chart import create_line_chart
|
6 |
+
from github_analytics.bubble_chart import create_bubble_chart
|
7 |
+
from github_analytics.bar_chart import create_bar_chart
|
8 |
+
|
9 |
+
|
10 |
+
def github_analytics():
|
11 |
+
"""Streamlit app for fetching and displaying GitHub user and repository data."""
|
12 |
+
st.title("Github Analytics")
|
13 |
+
username = st.text_input("Enter your GitHub username")
|
14 |
+
if username:
|
15 |
+
user_data, repo_data = fetch_user_data(username)
|
16 |
+
if user_data == "User not found":
|
17 |
+
st.error("User not found")
|
18 |
+
return
|
19 |
+
|
20 |
+
if repo_data == "Repo not found":
|
21 |
+
st.write("Repo not found")
|
22 |
+
return
|
23 |
+
|
24 |
+
if user_data:
|
25 |
+
if repo_data:
|
26 |
+
display_user_info(user_data)
|
27 |
+
# st.write("**User Info:**")
|
28 |
+
# st.write(user_data)
|
29 |
+
# st.write("**Repo Info:**")
|
30 |
+
# st.write(repo_data)
|
31 |
+
|
32 |
+
st.title("Select a metric to analyze")
|
33 |
+
option = st.selectbox(
|
34 |
+
"",
|
35 |
+
("Stars", "Forks", "Languages Used",
|
36 |
+
"Stars and Forks compared with time"),
|
37 |
+
index=None,
|
38 |
+
placeholder="Select something...",
|
39 |
+
)
|
40 |
+
|
41 |
+
st.write("You selected:", option)
|
42 |
+
|
43 |
+
# Dictionary to map options to functions
|
44 |
+
option_functions = {
|
45 |
+
"Stars": create_bar_chart,
|
46 |
+
"Forks": create_line_chart,
|
47 |
+
"Languages Used": create_pie_chart,
|
48 |
+
"Stars and Forks compared with time": create_bubble_chart,
|
49 |
+
}
|
50 |
+
|
51 |
+
# Call the corresponding function based on the selected option
|
52 |
+
if option in option_functions:
|
53 |
+
option_functions[option](repo_data)
|
54 |
+
else:
|
55 |
+
st.warning("Invalid option selected.")
|
56 |
+
|
57 |
+
else:
|
58 |
+
st.error(f"No repositories found for the user '{username}'.")
|
59 |
+
else:
|
60 |
+
st.title(f"Invalid username '{username}'. Please enter a valid GitHub username.")
|