Lines
96.42%
27 / 28
Functions and Methods
75.00%
3 / 4
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Log | 96.42% | 27 / 28 | 75.00% | 3 / 4 | 4 | 0.00% | 0 / 1 | |||
| getEntityMapping | 100.00% | 21 / 21 | 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 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsbackend\Log\Repository; | |
| 4 | ||
| 5 | class Log extends \BO\Zmsbackend\Query\Base | |
| 6 | { | |
| 7 | /** | |
| 8 | * @var String TABLE mysql table reference | |
| 9 | */ | |
| 10 | const string 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 ' . \BO\Zmsbackend\Mail\Repository\Mimepart::TABLE . ' mp ON mp.queueId = mq.id | |
| 21 | WHERE mq.processID=? | |
| 22 | '; | |
| 23 | ||
| 24 | /** | |
| 25 | * @psalm-api | |
| 26 | * | |
| 27 | * @return string[] | |
| 28 | * | |
| 29 | */ | |
| 30 | public function getEntityMapping(): array | |
| 31 | { | |
| 32 | return [ | |
| 33 | 'type' => 'log.type', | |
| 34 | 'reference' => 'log.reference_id', | |
| 35 | 'scope_id' => 'log.scope_id', | |
| 36 | 'user_id' => 'log.user_id', | |
| 37 | 'message' => 'log.message', | |
| 38 | 'ts' => 'log.ts', | |
| 39 | 'action' => 'log.action', | |
| 40 | 'display_number' => 'log.display_number', | |
| 41 | 'queue_number' => 'log.queue_number', | |
| 42 | 'appointment_at' => 'log.appointment_at', | |
| 43 | 'slot_count' => 'log.slot_count', | |
| 44 | 'citizen_name' => 'log.citizen_name', | |
| 45 | 'services' => 'log.services', | |
| 46 | 'scope_name' => 'log.scope_name', | |
| 47 | 'citizen_email' => 'log.citizen_email', | |
| 48 | 'citizen_phone' => 'log.citizen_phone', | |
| 49 | 'process_status' => 'log.process_status', | |
| 50 | 'db_status' => 'log.db_status', | |
| 51 | 'process_amendment' => 'log.process_amendment', | |
| 52 | ]; | |
| 53 | } | |
| 54 | ||
| 55 | public function addConditionProcessId($processId): static | |
| 56 | { | |
| 57 | $this->query->where('log.reference_id', '=', $processId); | |
| 58 | $this->query->where('log.type', '=', 'buerger'); | |
| 59 | $this->query->orderBy('log.ts', 'DESC'); | |
| 60 | return $this; | |
| 61 | } | |
| 62 | ||
| 63 | #[\Override] | |
| 64 | public function postProcess($data) | |
| 65 | { | |
| 66 | $data[$this->getPrefixed('ts')] = strtotime($data[$this->getPrefixed('ts')]); | |
| 67 | return $data; | |
| 68 | } | |
| 69 | ||
| 70 | public function addConditionOlderThan(\DateTime $olderThanDate): void | |
| 71 | { | |
| 72 | $this->query->where('log.ts', '<', $olderThanDate->format('Y-m-d H:i:s')); | |
| 73 | } | |
| 74 | } |