-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchris_test.php
More file actions
96 lines (70 loc) · 3.09 KB
/
chris_test.php
File metadata and controls
96 lines (70 loc) · 3.09 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
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
<?php
/*************************************************************************************************
* Writen By: - Rachael Bran - rachael.bran@flashtalking.com
* Description: - Test Jira
* Date Created: - 29/07/2016
* Modifications: -
*
*************************************************************************************************/
// error_reporting(E_ALL);
// ini_set("display_errors","on");
// ini_set("display_startup_errors", "on");
// ini_set("ignore_repeated_errors", "on");
//set_time_limit(1000);
//ignore_user_abort(true);
class feedclass{
function __construct(){
}
function init(){
$url = "https://flashtalkingus.atlassian.net/rest/api/2/search?jql=project=CTSD%20AND%20status!=resolved&maxResults=200";
$jira_username = '##username##';
$jira_password = '##password##';
$CTSDInitial = $this->get_from($url, $jira_username, $jira_password);
// $fullUrl = "https://flashtalkingus.atlassian.net/rest/api/2/search?jql=project=CTSD&maxResults=" . $CTSDInitial->total;
// $CTSD = $this->get_from($fullUrl, $jira_username, $jira_password);
$strippedCTSDIssues = $this->stripCTSD($CTSDInitial->issues);
return $strippedCTSDIssues;
}
function stripCTSD($issue){
$open = 0;
$workingOnIt = 0;
$waitingOn = 0;
$waitingOnAdBuilder = 0;
$waitingOnJSDev = 0;
$waitingOnCreativeManager = 0;
if($issue){
foreach ($issue as $k => $v) {
if(strtolower($v->fields->status->name) === "open"){
$open += 1;
}else if(strtolower(@$v->fields->assignee->key) == "jsdev"){
$waitingOnJSDev += 1;
}else if(strtolower($v->fields->status->name) === "working on it" && strtolower(@$v->fields->assignee->key) !== "philwhitely" && strtolower(@$v->fields->assignee->key) !== "jsdev"){
$workingOnIt += 1;
}else if(strtolower(@$v->fields->labels[0]) === "adbuilder" && strtolower(@$v->fields->assignee->key) === "philwhitely"){
$waitingOnAdBuilder += 1;
}else if(strtolower(@$v->fields->labels[0]) === "creativemanager" && strtolower(@$v->fields->assignee->key) === "philwhitely"){
$waitingOnCreativeManager += 1;
}else if(strtolower($v->fields->status->name) === "waiting on..." && strtolower(@$v->fields->assignee->key) !== "philwhitely" && strtolower(@$v->fields->assignee->key) !== "jsdev"){
$waitingOn += 1;
}
}
$organisedData = array("open" => $open, "workingOnIt" => $workingOnIt, "waitingOn..." => $waitingOn, "waitingOnAdBuilder" => $waitingOnAdBuilder, "waitingOnjsDev" => $waitingOnJSDev, "waitingOnCreativeManager" => $waitingOnCreativeManager);
}else{
$organisedData = array("open" => 0, "workingOnIt" => 0, "waitingOn..." => 0, "waitingOnAdBuilder" => 0, "waitingOnjsDev" => 0, "waitingOnCreativeManager" => 0);
}
return $organisedData;
}
function get_from($url, $jira_username, $jira_password) {
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_USERPWD => $jira_username . ':' . $jira_password,
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
CURLOPT_RETURNTRANSFER => true
));
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result);
}
}
?>