forked from OpenRSI/5MCSI_Metriques
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_commits.py
More file actions
32 lines (24 loc) · 1.03 KB
/
github_commits.py
File metadata and controls
32 lines (24 loc) · 1.03 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
from urllib.request import urlopen
from collections import defaultdict
from datetime import datetime
import json
def get_commits():
url = "https://api.github.com/repos/blablapola/5MCSI_Metriques/commits"
# Utiliser urllib pour faire une requête GET
response = urlopen(url)
# Lire et décoder la réponse
raw_data = response.read().decode('utf-8')
# Charger la réponse JSON
commits = json.loads(raw_data)
# Dictionnaire pour compter les commits par minute
commit_per_minute = defaultdict(int)
for commit in commits:
commit_date_str = commit['commit']['author']['date']
commit_date = datetime.strptime(commit_date_str, "%Y-%m-%dT%H:%M:%SZ")
commit_minute = commit_date.strftime("%Y-%m-%d %H:%M")
commit_per_minute[commit_minute] += 1
# Préparer les données pour le graphique
chart_data = [["Minute", "Nombre de commits"]]
for minute, count in sorted(commit_per_minute.items()):
chart_data.append([minute, count])
return chart_data