Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96196783
PhabricatorSearchFerretNgramGarbageCollector.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
Mon, Dec 23, 16:30
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 16:30 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23142584
Attached To
rPH Phabricator
PhabricatorSearchFerretNgramGarbageCollector.php
View Options
<?php
final
class
PhabricatorSearchFerretNgramGarbageCollector
extends
PhabricatorGarbageCollector
{
const
COLLECTORCONST
=
'search.ferret.ngram'
;
public
function
getCollectorName
()
{
return
pht
(
'Ferret Engine Ngrams'
);
}
public
function
hasAutomaticPolicy
()
{
return
true
;
}
protected
function
collectGarbage
()
{
$all_objects
=
id
(
new
PhutilClassMapQuery
())
->
setAncestorClass
(
'PhabricatorFerretInterface'
)
->
execute
();
$did_collect
=
false
;
foreach
(
$all_objects
as
$object
)
{
$engine
=
$object
->
newFerretEngine
();
$conn
=
$object
->
establishConnection
(
'w'
);
$ngram_row
=
queryfx_one
(
$conn
,
'SELECT ngram FROM %T WHERE needsCollection = 1 LIMIT 1'
,
$engine
->
getCommonNgramsTableName
());
if
(!
$ngram_row
)
{
continue
;
}
$ngram
=
$ngram_row
[
'ngram'
];
queryfx
(
$conn
,
'DELETE FROM %T WHERE ngram = %s'
,
$engine
->
getNgramsTableName
(),
$ngram
);
queryfx
(
$conn
,
'UPDATE %T SET needsCollection = 0 WHERE ngram = %s'
,
$engine
->
getCommonNgramsTableName
(),
$ngram
);
$did_collect
=
true
;
break
;
}
return
$did_collect
;
}
}
Event Timeline
Log In to Comment