-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreport.php
117 lines (100 loc) · 3.64 KB
/
report.php
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)');
$branch="master";
$page="1";
$since="2016-06-01";
$until="2017-07-01";
$portlets = array("FeedbackPortlet", "SimpleContentPortlet", "AnnouncementsPortlet", "CalendarPortlet", "EsupTwitter", "CalendarPortlet", "BookmarksPortlet", "CoursesPortlet", "email-preview", "JasigWidgetPortlets", "MapPortlet", "NewsReaderPortlet", "NotificationPortlet", "SurveyPortlet", "WeatherPortlet", "WebproxyPortlet", "portlet-utils", "basiclti-portlet", "ContactsPortlet", "ClassifiedsPortlet");
$username="";
$token="";
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$token")
)
));
$committers = array();
class User {
public $name;
public $email;
public $data;
public $commits;
}
function add_user($name, $email, $date) {
global $committers;
$exists = 0;
for ($i = 0; $i < count($committers); $i++) {
if ($committers[$i]->email == $email || $committers[$i]->name == $name) {
$exists = 1;
$committers[$i]->commits = $committers[$i]->commits + 1;
}
}
if ($exists == 0) {
$user = new User;
$user->name = $name;
$user->email = $email;
$user->date = $date;
$user->commits = $user->commits+1;
array_push($committers, $user);
}
}
$receiving = true;
$page = 1;
while($receiving) {
$url = "https://api.github.com/repos/jasig/uPortal/commits?since=$since&until=$until&per_page=100&page=$page&sha=$branch";
$results = file_get_contents($url, false, $context);
$json_results = json_decode($results);
if (count($json_results) > 0) {
for ($i = 0; $i < count($json_results); $i++) {
$user = add_user($json_results[$i]->commit->author->name, $json_results[$i]->commit->author->email, $json_results[$i]->commit->author->date);
}
} else {
$receiving = false;
}
$page++;
}
echo "Master branch committers\n";
for ($i = 0; $i < count($committers); $i++) {
print_r($committers[$i]->name . " " . $committers[$i]->commits . "\n");
}
$receiving = true;
$page = 1;
while($receiving) {
$url = "https://api.github.com/repos/jasig/uPortal/commits?since=$since&until=$until&per_page=100&page=$page&sha=rel-4-3-patches";
$results = file_get_contents($url, false, $context);
$json_results = json_decode($results);
if (count($json_results) > 0) {
for ($i = 0; $i < count($json_results); $i++) {
$user = add_user($json_results[$i]->commit->author->name, $json_results[$i]->commit->author->email, $json_results[$i]->commit->author->date);
}
} else {
$receiving = false;
}
$page++;
}
echo "\n\nMaster and rel-4-3-patches branch committers\n";
for ($i = 0; $i < count($committers); $i++) {
print_r($committers[$i]->name . " " . $committers[$i]->commits . "\n");
}
$committers = array();
for ($j = 0; $j < count($portlets); $j++) {
$receiving = true;
$page = 1;
while($receiving) {
$url = "https://api.github.com/repos/jasig/".$portlets[$j]."/commits?since=$since&until=$until&per_page=100&page=$page&sha=master";
$results = file_get_contents($url, false, $context);
$json_results = json_decode($results);
if (count($json_results) > 0) {
for ($i = 0; $i < count($json_results); $i++) {
$user = add_user($json_results[$i]->commit->author->name, $json_results[$i]->commit->author->email, $json_results[$i]->commit->author->date);
}
} else {
$receiving = false;
}
$page++;
}
}
echo "\n\nuPortal Portlet and Supporting Artifact committers\n";
for ($i = 0; $i < count($committers); $i++) {
print_r($committers[$i]->name . " " . $committers[$i]->commits . "\n");
}
?>