My site has ~100 feeds to leech. Most of them have a retention period of 2 weeks.
Old items are simply not being deleted. Nothing is has been deleted for more than a month. I have no idea why. Any ideas?
The problem is quite urgent, my database is growing very quickly.

CommentFileSizeAuthor
#8 feedapi-per-feed-delete-interval.png19.37 KBaron novak

Comments

aron novak’s picture

Assigned: Unassigned » aron novak
Status: Active » Fixed

Thanks for reporting this!
Actually this feature was simply not implemented. You can find the fix at the CVS.
You can patch your file according this: http://cvs.drupal.org/viewcvs/drupal/contributions/modules/leech/leech.m...

zis’s picture

Thx.
I'll test it soon.

Perhaps it would be better to aka the table names in the query. Check the snippet below.

  // Delete too old items
  	   $result = db_query("SELECT f.items_delete, n.created, i.nid
  	            FROM {node} AS n, {leech_news_item} AS i, {leech_news_feed} AS f
  	            WHERE ( n.nid = i.nid AND
  	                    f.nid = i.fid)"
  	   );
  	   $now = time();
  	   while ($node = db_fetch_object($result))  {
  	     if (abs($now - $node->created) > $node->items_delete) {
  	       node_delete($node->nid);
  	     }
  	   }
aron novak’s picture

Thanks for this advice!
I changed this part of the code, it's really much nicer :)
Have you tested it? Any experience?

zis’s picture

Status: Fixed » Needs work

I tested it, and it is working allright.
But, i think it would be better to check for old items for each feed at a time rather than checking the whole database at once. This way, after a feed is refreshed, only that feed is checked for old items..

Because I had a couple thousand old items, the script timmed out a couple of times before deleting them all.
One more thing, i can't seem to find a hook_delete function for feed items, i might have missed it though.

aron novak’s picture

Status: Needs work » Fixed

Thanks for trying out the solution.
Yes, you mentioned that the script ran into timeout. But if this deletion-stuff would work okay nicely, it couldn't happened i think.
hook_delete: the node_delete does the job what you mentioned.

zis’s picture

Status: Fixed » Needs review

I really think it should be set up to delete items on a per feed basis.

If a site aggregates 100 items/day, 1 cron run will have to delete 100 items in 1 time.. which is very time consuming..
if it is set to items on a per feed basis, the 100 items will spread to multiple runs..

aron novak’s picture

Unfortunately now I don't have time to implement your suggestion (the suggestion is good) about the per feed basis deletion. If you implement it, I'm glad if you can send a patch :) Ask me if any help is needed you to do this.

aron novak’s picture

Title: Old items not deleted » delete items on a per feed basis
Category: bug » feature
Priority: Critical » Normal
Status: Needs review » Closed (won't fix)
StatusFileSize
new19.37 KB

I would like to suggest you FeedAPI, there this feature is implemented already. Let's look at the attached screenshot.