forked from friendica/friendica-addons
this is more correct
This commit is contained in:
parent
c696cb174e
commit
ec24589166
|
@ -174,11 +174,11 @@ function retriever_clean_up_completed_resources($max_items) {
|
||||||
// TODO: figure out how to do this with DBA module
|
// TODO: figure out how to do this with DBA module
|
||||||
$r = DBA::p('SELECT retriever_resource.`id` as resource, retriever_item.`id` as item FROM retriever_resource, retriever_item, retriever_rule WHERE retriever_item.`finished` = 0 AND retriever_item.`resource` = retriever_resource.`id` AND retriever_resource.`completed` IS NOT NULL AND retriever_item.`contact-id` = retriever_rule.`contact-id` AND retriever_item.`item-uid` = retriever_rule.`uid` LIMIT %d',
|
$r = DBA::p('SELECT retriever_resource.`id` as resource, retriever_item.`id` as item FROM retriever_resource, retriever_item, retriever_rule WHERE retriever_item.`finished` = 0 AND retriever_item.`resource` = retriever_resource.`id` AND retriever_resource.`completed` IS NOT NULL AND retriever_item.`contact-id` = retriever_rule.`contact-id` AND retriever_item.`item-uid` = retriever_rule.`uid` LIMIT %d',
|
||||||
intval($max_items));
|
intval($max_items));
|
||||||
if (!$r) {
|
if (!DBA::isResult($r)) {
|
||||||
$r = array();
|
return;
|
||||||
}
|
}
|
||||||
Logger::debug('retriever_clean_up_completed_resources: items waiting even though resource has completed: ' . count($r));
|
Logger::debug('retriever_clean_up_completed_resources: items waiting even though resource has completed: ' . DBA::numRows($r));
|
||||||
foreach ($r as $rr) {
|
while ($rr = DBA::fetch($r)) {
|
||||||
$retriever_item = DBA::selectFirst('retriever_item', [], ['id' => intval($rr['item'])]);
|
$retriever_item = DBA::selectFirst('retriever_item', [], ['id' => intval($rr['item'])]);
|
||||||
if (!DBA::isResult($retriever_item)) {
|
if (!DBA::isResult($retriever_item)) {
|
||||||
Logger::warning('retriever_clean_up_completed_resources: no retriever item with id ' . $rr['item']);
|
Logger::warning('retriever_clean_up_completed_resources: no retriever item with id ' . $rr['item']);
|
||||||
|
@ -210,11 +210,11 @@ function retriever_tidy() {
|
||||||
DBA::delete('retriever_resource', ['completed IS NULL AND created < DATE_SUB(now(), INTERVAL 3 MONTH)']);
|
DBA::delete('retriever_resource', ['completed IS NULL AND created < DATE_SUB(now(), INTERVAL 3 MONTH)']);
|
||||||
|
|
||||||
$r = DBA::p("SELECT retriever_item.id FROM retriever_item LEFT OUTER JOIN retriever_resource ON (retriever_item.resource = retriever_resource.id) WHERE retriever_resource.id is null");
|
$r = DBA::p("SELECT retriever_item.id FROM retriever_item LEFT OUTER JOIN retriever_resource ON (retriever_item.resource = retriever_resource.id) WHERE retriever_resource.id is null");
|
||||||
if (!DBA::isResult($r)) {
|
if (!DBA::isResult($r)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Logger::info('retriever_tidy: found ' . count($r) . ' retriever_items with no retriever_resource');
|
Logger::info('retriever_tidy: found ' . DBA::numRows($r) . ' retriever_items with no retriever_resource');
|
||||||
foreach ($r as $rr) {
|
while ($rr = DBA::fetch($r)) {
|
||||||
DBA::e('DELETE FROM retriever_item WHERE id = %d', intval($rr['id']));
|
DBA::e('DELETE FROM retriever_item WHERE id = %d', intval($rr['id']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue