-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_data.php
193 lines (180 loc) · 4.28 KB
/
random_data.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
header( 'Content-Type: application/json' );
/*main functions*/
function random_pcent(){
return rand( 0, 99 ) ;
}
function random_value(){
return rand( 20, 80 ) ;
}
function random_pie(){
return rand( 70, 300 ) ;
}
function random_status(){
$value_s = rand( 1, 3 ) ;
switch ( $value_s ) {
case 1:
return "rejected" ;
break;
case 2:
return "complete" ;
break;
case 3:
return "accepted" ;
break;
/*case 4:
return "none" ; //fixing status data
break;*/
default:
print "error" ;
return ;
break;
}
}
function random_way_v(){
$value_v = rand( 1, 2 ) ;
switch ( $value_v ) {
case 1:
return "up" ;
break;
case 2:
return "down" ;
break;
default:
print "error" ;
return ;
break;
}
}
function random_way_h(){
$value_h = rand( 1, 2 ) ;
switch ( $value_h ) {
case 1:
return "left" ;
break;
case 2:
return "right" ;
break;
default:
print "error" ;
return ;
break;
}
}
/*/functions*/
$default_options = Array(
"0" => Array(
"type" => "build",
"name" => "Tenrox-R1_1235",
"owner" => "",
"date" => "",
"state" => "pending",
"final_status" => "Pending"
),
"1" => Array(
"type" => "firewall",
"name" => "432462",
"owner" => "jtuck",
"date" => "4/18/2014 12:12pm",
"state" => "running",
"final_status" => "Still Running"
),
"2" => Array(
"type" => "firewall",
"name" => "432461",
"owner" => "samy",
"date" => "4/18/2014 10:53pm",
"state" => "rejected",
"final_status" => "Metrics Reduction"
),
"3" => Array(
"debug" => "open",
"type" => "build",
"name" => "Tenrox-R1_1234",
"owner" => "",
"date" => "4/17/2014 9:42am",
"state" => "complete",
"final_status" => "Complete"
),
"4" => Array(
"type" => "firewall",
"name" => "432460",
"owner" => "samy",
"date" => "4/17/2014 7:51am",
"state" => "rejected",
"final_status" => "Metrics Reduction"
),
"5" => Array(
"type" => "firewall",
"name" => "432459",
"owner" => "samy",
"date" => "4/16/2014 6:43am",
"state" => "accepted",
"final_status" => "Auto-Merged"
)
) ;
//setting random data
$data = Array() ;
//set it at all (PUSH IN THE ARRAY FOR RETURNING)
for ( $i = 0 ; $i < 6 ; $i++ ) {
$unit_code_covered = random_pie() ;
$unit_code_not_covered = random_pie() ;
$functional_code_covered = random_pie() ;
$functional_code_not_covered = random_pie() ;
$unit_pcent_code_covered = intval( ( $unit_code_covered * 100 ) / ( $unit_code_covered + $unit_code_not_covered ) ) ;
$functional_pcent_code_covered = intval( ( $functional_code_covered * 100 ) / ( $functional_code_covered + $functional_code_not_covered ) ) ;
$data[ $i ] = Array(
"id" => $i,
"type" => $default_options[ $i ][ "type" ],
"name" => $default_options[ $i ][ "name" ],
"owner" => $default_options[ $i ][ "owner" ],
"date" => $default_options[ $i ][ "date" ],
"state" => $default_options[ $i ][ "state" ],
"final_status" => $default_options[ $i ][ "final_status" ],
"metrics" => Array(
"total" => random_pcent(),
"metrics_st" => random_status(),
"test" => Array(
"n" => random_value(),
"way" => random_way_v()
),
"maint" => Array(
"n" => random_value(),
"way" => random_way_v()
),
"sec" => Array(
"n" => random_value(),
"way" => random_way_h()
),
"work" => Array(
"n" => random_value(),
"way" => random_way_h()
)
),
"build" => Array(
"total" => random_pcent(),
"build_st" => random_status(),
"date_build" => $default_options[ $i ][ "date" ]
),
"unit" => Array(
"total" => random_pcent(),
"unit_st" => random_status(),
"msg" => "tests passed",
"code_covered" => $unit_code_covered,
"code_not_covered" => $unit_code_not_covered,
"code_covered_pcent" => $unit_pcent_code_covered
),
"functional" => Array(
"total" => random_pcent(),
"functional_st" => random_status(),
"msg" => "tests passed",
"code_covered" => $functional_code_covered,
"code_not_covered" => $functional_code_not_covered,
"code_covered_pcent" => $functional_pcent_code_covered
),
"debug" => $default_options[ $i ][ "debug" ]
) ;
}
//echo on this page
echo json_encode( $data ) ;
?>