Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Issue #267 - follow-up fix
Browse files Browse the repository at this point in the history
  • Loading branch information
swentel committed Dec 9, 2018
1 parent 89c4143 commit d283b71
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public function removeItemsBySourceOlderThanTimestamp($timestamp, $source_id) {
->delete('microsub_item')
->condition('timestamp', $timestamp, '<')
->condition('source_id', $source_id)
->condition('is_read', 1)
->execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public function updateItemsToNewChannel($source_id, $channel_id);
public function itemExists($source_id, $guid);

/**
* Removes items by source and older than created time.
* Removes items by source and older than created time and is unread.
*
* @param $created
* @param $timestamp
* The microsub item created time
* @param $source_id
* The source id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function fetchItems() {
$url = $source->label();
$tries = $source->getTries();
$item_count = $source->getItemCount();
$empty = $item_count== 0;
$empty = $item_count == 0;
$source_id = $source->id();
$channel_id = $source->getChannelId();
$disable_image_cache = $source->disableImageCache();
Expand Down Expand Up @@ -94,7 +94,7 @@ public function fetchItems() {

// Cleanup old items if we can. We do this here because it doesn't
// make much sense to check this if the hash hasn't changed.
if (!$empty && $cleanup_old_items && $items_in_feed && $items_to_keep && $items_in_feed >= $item_count) {
if (!$empty && $cleanup_old_items && $items_in_feed && $items_to_keep && $item_count >= $items_to_keep) {
// We use two queries as not all mysql servers understand limits
// in sub queries when the main query is a delete.
$timestamp = \Drupal::entityTypeManager()->getStorage('indieweb_microsub_item')->getTimestampByRangeAndSource($items_to_keep, $source_id);
Expand Down Expand Up @@ -395,4 +395,4 @@ protected function getAuthor(&$post, $webmention) {
}
}

}
}

0 comments on commit d283b71

Please sign in to comment.