1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Index\Queue\Statistic; |
4
|
|
|
|
5
|
|
|
/*************************************************************** |
6
|
|
|
* Copyright notice |
7
|
|
|
* |
8
|
|
|
* (c) 2017 Timo Hund <[email protected]> |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
class QueueStatistic |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var int |
33
|
|
|
*/ |
34
|
|
|
protected $failedCount = 0; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var int |
38
|
|
|
*/ |
39
|
|
|
protected $pendingCount = 0; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var int |
43
|
|
|
*/ |
44
|
|
|
protected $successCount = 0; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param int $failedCount |
48
|
|
|
*/ |
49
|
2 |
|
public function setFailedCount($failedCount) |
50
|
|
|
{ |
51
|
2 |
|
$this->failedCount = $failedCount; |
52
|
2 |
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return int |
56
|
|
|
*/ |
57
|
2 |
|
public function getFailedCount() |
58
|
|
|
{ |
59
|
2 |
|
return $this->failedCount; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return float|int |
64
|
|
|
*/ |
65
|
1 |
|
public function getFailedPercentage() |
66
|
|
|
{ |
67
|
1 |
|
return $this->getPercentage($this->getFailedCount()); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param int $pendingCount |
72
|
|
|
*/ |
73
|
2 |
|
public function setPendingCount($pendingCount) |
74
|
|
|
{ |
75
|
2 |
|
$this->pendingCount = $pendingCount; |
76
|
2 |
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return int |
80
|
|
|
*/ |
81
|
2 |
|
public function getPendingCount() |
82
|
|
|
{ |
83
|
2 |
|
return $this->pendingCount; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return float|int |
88
|
|
|
*/ |
89
|
1 |
|
public function getPendingPercentage() |
90
|
|
|
{ |
91
|
1 |
|
return $this->getPercentage($this->getPendingCount()); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param int $successCount |
96
|
|
|
*/ |
97
|
2 |
|
public function setSuccessCount($successCount) |
98
|
|
|
{ |
99
|
2 |
|
$this->successCount = $successCount; |
100
|
2 |
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return int |
104
|
|
|
*/ |
105
|
2 |
|
public function getSuccessCount() |
106
|
|
|
{ |
107
|
2 |
|
return $this->successCount; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return float|int |
112
|
|
|
*/ |
113
|
1 |
|
public function getSuccessPercentage() |
114
|
|
|
{ |
115
|
1 |
|
return $this->getPercentage($this->getSuccessCount()); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return int |
120
|
|
|
*/ |
121
|
1 |
|
public function getTotalCount() |
122
|
|
|
{ |
123
|
1 |
|
return $this->pendingCount + $this->failedCount + $this->successCount; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param integer $count |
128
|
|
|
* @return float|int |
129
|
|
|
*/ |
130
|
1 |
|
protected function getPercentage($count) |
131
|
|
|
{ |
132
|
1 |
|
return round((100 / $this->getTotalCount()) * $count, 2); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|