Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
15 / 20 |
|
60.00% |
3 / 5 |
CRAP | |
0.00% |
0 / 1 |
| Log | |
75.00% |
15 / 20 |
|
60.00% |
3 / 5 |
6.56 | |
0.00% |
0 / 1 |
| getEntityMapping | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| addConditionProcessId | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| postProcess | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| addConditionOlderThan | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| addConditionDataSearch | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Zmsdb\Query; |
| 4 | |
| 5 | class Log extends Base |
| 6 | { |
| 7 | /** |
| 8 | * @var String TABLE mysql table reference |
| 9 | */ |
| 10 | const TABLE = 'log'; |
| 11 | |
| 12 | /** |
| 13 | * No resolving required here |
| 14 | */ |
| 15 | protected $resolveLevel = 0; |
| 16 | |
| 17 | const QUERY_DELETE_BY_PROCESS = ' |
| 18 | DELETE mq, mp |
| 19 | FROM ' . self::TABLE . ' mq |
| 20 | LEFT JOIN ' . Mimepart::TABLE . ' mp ON mp.queueId = mq.id |
| 21 | WHERE mq.processID=? |
| 22 | '; |
| 23 | |
| 24 | public function getEntityMapping() |
| 25 | { |
| 26 | return [ |
| 27 | 'type' => 'log.type', |
| 28 | 'reference' => 'log.reference_id', |
| 29 | 'scope_id' => 'log.scope_id', |
| 30 | 'user_id' => 'log.user_id', |
| 31 | 'data' => 'log.data', |
| 32 | 'message' => 'log.message', |
| 33 | 'ts' => 'log.ts' |
| 34 | ]; |
| 35 | } |
| 36 | |
| 37 | public function addConditionProcessId($processId) |
| 38 | { |
| 39 | $this->query->where('log.reference_id', '=', $processId); |
| 40 | $this->query->where('log.type', '=', 'buerger'); |
| 41 | $this->query->orderBy('log.ts', 'DESC'); |
| 42 | return $this; |
| 43 | } |
| 44 | |
| 45 | public function postProcess($data) |
| 46 | { |
| 47 | $data[$this->getPrefixed('ts')] = strtotime($data[$this->getPrefixed('ts')]); |
| 48 | return $data; |
| 49 | } |
| 50 | |
| 51 | public function addConditionOlderThan(\DateTime $olderThanDate) |
| 52 | { |
| 53 | $this->query->where('log.ts', '<', $olderThanDate->format('Y-m-d H:i:s')); |
| 54 | } |
| 55 | |
| 56 | public function addConditionDataSearch(string $search) |
| 57 | { |
| 58 | $this->query->where('log.data', 'LIKE', '%' . $search . '%'); |
| 59 | |
| 60 | if (is_numeric($search)) { |
| 61 | $this->query->orWhere('log.reference_id', '=', $search); |
| 62 | } |
| 63 | |
| 64 | $this->query->orderBy('log.ts', 'DESC'); |
| 65 | } |
| 66 | } |