blob: d776622f9b3d29c115cb3e7479051f313b9834c2 (
plain)
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
|
<?php
/* Icinga Web 2 X.509 Module | (c) 2022 Icinga GmbH | GPLv2 */
namespace Icinga\Module\X509\Model;
use DateTime;
use ipl\Orm\Behavior\MillisecondTimestamp;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Query;
use ipl\Orm\Relations;
/**
* A database model for all x509 job schedules
*
* @property int $id Unique identifier of this job
* @property ?int $job_id The id of the x509 job this job run belongs to
* @property ?int $schedule_id The id of the x509 job schedule this run belongs to
* @property int $total_targets All the x509 targets found by this job run
* @property int $finished_targets All the x509 targets scanned by this job run
* @property DateTime $start_time The start time of this job run
* @property DateTime $end_time The end time of this job run
* @property Query|X509Job $job The x509 job this job run belongs to
* @property Query|X509Schedule $schedule The x509 job schedule this job run belongs to
*/
class X509JobRun extends Model
{
public function getTableName(): string
{
return 'x509_job_run';
}
public function getTableAlias(): string
{
return 'job_run';
}
public function getKeyName()
{
return 'id';
}
public function getColumns(): array
{
return [
'job_id',
'schedule_id',
'total_targets',
'finished_targets',
'start_time',
'end_time'
];
}
public function getDefaultSort(): string
{
return 'start_time desc';
}
public function createBehaviors(Behaviors $behaviors): void
{
$behaviors->add(new MillisecondTimestamp([
'start_time',
'end_time',
]));
}
public function createRelations(Relations $relations): void
{
$relations->belongsTo('job', X509Job::class)
->setCandidateKey('job_id');
$relations->belongsTo('schedule', X509Schedule::class)
->setJoinType('LEFT')
->setCandidateKey('schedule_id');
}
}
|