Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93534441
PhabricatorDaemonTaskGarbageCollector.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 29, 12:58
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Dec 1, 12:58 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22658496
Attached To
rPH Phabricator
PhabricatorDaemonTaskGarbageCollector.php
View Options
<?php
final
class
PhabricatorDaemonTaskGarbageCollector
extends
PhabricatorGarbageCollector
{
const
COLLECTORCONST
=
'worker.tasks'
;
public
function
getCollectorName
()
{
return
pht
(
'Archived Tasks'
);
}
public
function
getDefaultRetentionPolicy
()
{
return
phutil_units
(
'14 days in seconds'
);
}
protected
function
collectGarbage
()
{
$table
=
new
PhabricatorWorkerArchiveTask
();
$data_table
=
new
PhabricatorWorkerTaskData
();
$conn_w
=
$table
->
establishConnection
(
'w'
);
$tasks
=
id
(
new
PhabricatorWorkerArchiveTaskQuery
())
->
withDateCreatedBefore
(
$this
->
getGarbageEpoch
())
->
setLimit
(
100
)
->
execute
();
if
(!
$tasks
)
{
return
false
;
}
$data_ids
=
array_filter
(
mpull
(
$tasks
,
'getDataID'
));
$task_ids
=
mpull
(
$tasks
,
'getID'
);
$table
->
openTransaction
();
if
(
$data_ids
)
{
queryfx
(
$conn_w
,
'DELETE FROM %T WHERE id IN (%Ld)'
,
$data_table
->
getTableName
(),
$data_ids
);
}
queryfx
(
$conn_w
,
'DELETE FROM %T WHERE id IN (%Ld)'
,
$table
->
getTableName
(),
$task_ids
);
$table
->
saveTransaction
();
return
(
count
(
$task_ids
)
==
100
);
}
}
Event Timeline
Log In to Comment