Skip to content

Commit 513407f

Browse files
committed
Add graph_gui_downloads python script to tools
1 parent 5095f6e commit 513407f

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tools/graph_gui_downloads.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import requests
2+
import matplotlib.pyplot as plt
3+
from datetime import datetime
4+
5+
# Define the GitHub API URL for the OpenBCI releases
6+
api_url = "https://api.github.com/repos/OpenBCI/OpenBCI_GUI/releases"
7+
8+
# Send a GET request to the API
9+
response = requests.get(api_url)
10+
11+
# Check if the request was successful
12+
if response.status_code != 200:
13+
print(f"Failed to fetch data. Status code: {response.status_code}")
14+
exit()
15+
16+
# Parse the JSON data
17+
data = response.json()
18+
19+
# Initialize dictionaries to store download counts for each platform
20+
download_count_mac = {}
21+
download_count_linux = {}
22+
download_count_windows = {}
23+
24+
# Extract download counts over time for each platform
25+
for release in data:
26+
assets = release.get("assets", [])
27+
release_date = datetime.strptime(release["published_at"], "%Y-%m-%dT%H:%M:%SZ").date()
28+
29+
for asset in assets:
30+
if "mac" in asset["name"].lower():
31+
download_count_mac[release_date] = download_count_mac.get(release_date, 0) + asset["download_count"]
32+
elif "linux" in asset["name"].lower():
33+
download_count_linux[release_date] = download_count_linux.get(release_date, 0) + asset["download_count"]
34+
elif "win" in asset["name"].lower():
35+
download_count_windows[release_date] = download_count_windows.get(release_date, 0) + asset["download_count"]
36+
37+
# Extract dates and download counts for each platform
38+
dates_mac, counts_mac = zip(*sorted(download_count_mac.items()))
39+
dates_linux, counts_linux = zip(*sorted(download_count_linux.items()))
40+
dates_windows, counts_windows = zip(*sorted(download_count_windows.items()))
41+
42+
# Create the download count graphs
43+
plt.figure(figsize=(12, 6))
44+
plt.plot(dates_mac, counts_mac, label="Mac", marker='o')
45+
plt.plot(dates_linux, counts_linux, label="Linux", marker='o')
46+
plt.plot(dates_windows, counts_windows, label="Windows", marker='o')
47+
48+
plt.title("Download Count Over Time for OpenBCI GUI")
49+
plt.xlabel("Release Date")
50+
plt.ylabel("Download Count")
51+
plt.grid(True)
52+
plt.legend()
53+
54+
# Rotate x-axis labels for better readability
55+
plt.xticks(rotation=45)
56+
57+
# Show the graph
58+
plt.tight_layout()
59+
plt.show()

0 commit comments

Comments
 (0)