From 77fb82d6aed67de721b2241adbc84c2f36e90a0e Mon Sep 17 00:00:00 2001 From: jamesl1001 Date: Fri, 20 Jun 2014 23:36:00 +0100 Subject: [PATCH 1/4] Add Github stats --- front-controller.php | 5 +++++ model-fyp.php | 29 +++++++++++++++++++++++++++++ views/fyp.php | 11 +++++++++++ 3 files changed, 45 insertions(+) create mode 100644 model-fyp.php diff --git a/front-controller.php b/front-controller.php index 7c26de0..a73b85d 100644 --- a/front-controller.php +++ b/front-controller.php @@ -24,6 +24,7 @@ $isNewEnv = preg_match('#env\/new/?$#', $q); $isRecentlyClonedEnvs = preg_match('#recently-cloned-environments/?$#', $q); $isCapturing = preg_match('#capturing-environment#', $q); +$isFYP = preg_match('#fyp#', $q); $currentUrl = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; @@ -48,4 +49,8 @@ $file = 'recently-cloned-environments'; } +if($isFYP) { + require_once('model-fyp.php'); +} + require_once('front-view.php'); \ No newline at end of file diff --git a/model-fyp.php b/model-fyp.php new file mode 100644 index 0000000..bf178e2 --- /dev/null +++ b/model-fyp.php @@ -0,0 +1,29 @@ + 1, + CURLOPT_URL => $url, + CURLOPT_USERAGENT => 'JaL-User-Agent')); +$contributors = json_decode(curl_exec($curl)); + +var_dump($contributors); + +$commits = $contributors[0]->total + $contributors[1]->total + $contributors[2]->total; + +$url = 'https://api.github.com/repos/Precise-Pixels/cell/branches?per_page=999'; +$curl = curl_init(); +curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $url, + CURLOPT_USERAGENT => 'JaL-User-Agent')); +$branches = json_decode(curl_exec($curl)); + +$url = 'https://api.github.com/repos/Precise-Pixels/cell/pulls?state=all&per_page=999'; +$curl = curl_init(); +curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $url, + CURLOPT_USERAGENT => 'JaL-User-Agent')); +$pulls = json_decode(curl_exec($curl)); \ No newline at end of file diff --git a/views/fyp.php b/views/fyp.php index bb25a29..e3dead6 100644 --- a/views/fyp.php +++ b/views/fyp.php @@ -23,4 +23,15 @@ +
+
+

GITHUB INFO

+

URL: https://github.com/Precise-Pixels/cell

+

Language Distribution: PHP 48.9% | Javascript 29.2% | CSS 21.9%

+

Commits:

+

Branches:

+

Pull Requests:

+
+
+ \ No newline at end of file From a5ea4277a23b4c746bfe7f827aa2bad217617b98 Mon Sep 17 00:00:00 2001 From: jamesl1001 Date: Fri, 20 Jun 2014 23:36:00 +0100 Subject: [PATCH 2/4] Add Github stats --- front-controller.php | 5 +++++ model-fyp.php | 27 +++++++++++++++++++++++++++ views/fyp.php | 11 +++++++++++ 3 files changed, 43 insertions(+) create mode 100644 model-fyp.php diff --git a/front-controller.php b/front-controller.php index 7c26de0..a73b85d 100644 --- a/front-controller.php +++ b/front-controller.php @@ -24,6 +24,7 @@ $isNewEnv = preg_match('#env\/new/?$#', $q); $isRecentlyClonedEnvs = preg_match('#recently-cloned-environments/?$#', $q); $isCapturing = preg_match('#capturing-environment#', $q); +$isFYP = preg_match('#fyp#', $q); $currentUrl = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; @@ -48,4 +49,8 @@ $file = 'recently-cloned-environments'; } +if($isFYP) { + require_once('model-fyp.php'); +} + require_once('front-view.php'); \ No newline at end of file diff --git a/model-fyp.php b/model-fyp.php new file mode 100644 index 0000000..3d8787e --- /dev/null +++ b/model-fyp.php @@ -0,0 +1,27 @@ + 1, + CURLOPT_URL => $url, + CURLOPT_USERAGENT => 'JaL-User-Agent')); +$contributors = json_decode(curl_exec($curl)); + +$commits = $contributors[0]->total + $contributors[1]->total + $contributors[2]->total; + +$url = 'https://api.github.com/repos/Precise-Pixels/cell/branches?per_page=999'; +$curl = curl_init(); +curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $url, + CURLOPT_USERAGENT => 'JaL-User-Agent')); +$branches = json_decode(curl_exec($curl)); + +$url = 'https://api.github.com/repos/Precise-Pixels/cell/pulls?state=all&per_page=999'; +$curl = curl_init(); +curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $url, + CURLOPT_USERAGENT => 'JaL-User-Agent')); +$pulls = json_decode(curl_exec($curl)); \ No newline at end of file diff --git a/views/fyp.php b/views/fyp.php index bb25a29..e3dead6 100644 --- a/views/fyp.php +++ b/views/fyp.php @@ -23,4 +23,15 @@ +
+
+

GITHUB INFO

+

URL: https://github.com/Precise-Pixels/cell

+

Language Distribution: PHP 48.9% | Javascript 29.2% | CSS 21.9%

+

Commits:

+

Branches:

+

Pull Requests:

+
+
+ \ No newline at end of file From 035a7238ab9b934774b5852b9a48ba1095d57d14 Mon Sep 17 00:00:00 2001 From: jamesl1001 Date: Thu, 24 Jul 2014 13:39:36 +0100 Subject: [PATCH 3/4] Fix cURL error --- model-fyp.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/model-fyp.php b/model-fyp.php index 3d8787e..ff1d992 100644 --- a/model-fyp.php +++ b/model-fyp.php @@ -1,21 +1,23 @@ 1, CURLOPT_URL => $url, - CURLOPT_USERAGENT => 'JaL-User-Agent')); + CURLOPT_USERAGENT => 'JaL-User-Agent', + CURLOPT_SSL_VERIFYPEER => false)); $contributors = json_decode(curl_exec($curl)); -$commits = $contributors[0]->total + $contributors[1]->total + $contributors[2]->total; +$commits = $contributors[0]->contributions + $contributors[1]->contributions + $contributors[2]->contributions; $url = 'https://api.github.com/repos/Precise-Pixels/cell/branches?per_page=999'; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, - CURLOPT_USERAGENT => 'JaL-User-Agent')); + CURLOPT_USERAGENT => 'JaL-User-Agent', + CURLOPT_SSL_VERIFYPEER => false)); $branches = json_decode(curl_exec($curl)); $url = 'https://api.github.com/repos/Precise-Pixels/cell/pulls?state=all&per_page=999'; @@ -23,5 +25,6 @@ curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, - CURLOPT_USERAGENT => 'JaL-User-Agent')); + CURLOPT_USERAGENT => 'JaL-User-Agent', + CURLOPT_SSL_VERIFYPEER => false)); $pulls = json_decode(curl_exec($curl)); \ No newline at end of file From 8db446eb97c6aa1b37edf7e088a1ebfce2f46ee9 Mon Sep 17 00:00:00 2001 From: jamesl1001 Date: Thu, 24 Jul 2014 13:54:19 +0100 Subject: [PATCH 4/4] Get paginated data for branches and PRs --- model-fyp.php | 30 ++++++++++++++++++++++++++---- views/fyp.php | 4 ++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/model-fyp.php b/model-fyp.php index ff1d992..ac7b9cd 100644 --- a/model-fyp.php +++ b/model-fyp.php @@ -11,20 +11,42 @@ $commits = $contributors[0]->contributions + $contributors[1]->contributions + $contributors[2]->contributions; -$url = 'https://api.github.com/repos/Precise-Pixels/cell/branches?per_page=999'; +$url = 'https://api.github.com/repos/Precise-Pixels/cell/branches?per_page=100&page=1'; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, CURLOPT_USERAGENT => 'JaL-User-Agent', CURLOPT_SSL_VERIFYPEER => false)); -$branches = json_decode(curl_exec($curl)); +$branches1 = json_decode(curl_exec($curl)); -$url = 'https://api.github.com/repos/Precise-Pixels/cell/pulls?state=all&per_page=999'; +$url = 'https://api.github.com/repos/Precise-Pixels/cell/branches?per_page=100&page=2'; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, CURLOPT_USERAGENT => 'JaL-User-Agent', CURLOPT_SSL_VERIFYPEER => false)); -$pulls = json_decode(curl_exec($curl)); \ No newline at end of file +$branches2 = json_decode(curl_exec($curl)); + +$branches = count($branches1) + count($branches2); + +$url = 'https://api.github.com/repos/Precise-Pixels/cell/pulls?state=all&per_page=100&page=1'; +$curl = curl_init(); +curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $url, + CURLOPT_USERAGENT => 'JaL-User-Agent', + CURLOPT_SSL_VERIFYPEER => false)); +$pulls1 = json_decode(curl_exec($curl)); + +$url = 'https://api.github.com/repos/Precise-Pixels/cell/pulls?state=all&per_page=100&page=2'; +$curl = curl_init(); +curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $url, + CURLOPT_USERAGENT => 'JaL-User-Agent', + CURLOPT_SSL_VERIFYPEER => false)); +$pulls2 = json_decode(curl_exec($curl)); + +$pulls = count($pulls1) + count($pulls2); \ No newline at end of file diff --git a/views/fyp.php b/views/fyp.php index ae5e660..b7b0b4b 100644 --- a/views/fyp.php +++ b/views/fyp.php @@ -32,8 +32,8 @@

URL: https://github.com/Precise-Pixels/cell

Language Distribution: PHP 49.5% | Javascript 29.5% | CSS 21.0%

Commits:

-

Branches:

-

Pull Requests:

+

Branches:

+

Pull Requests: