Check item remoteId presence with its foreign feedId

This commit is contained in:
Shinokuni 2019-06-14 14:52:03 +02:00
parent 9cb3c14e40
commit 65c7141c29
2 changed files with 7 additions and 5 deletions

View File

@ -25,8 +25,8 @@ public interface ItemDao {
@Query("Select case When :guid In (Select guid from Item) Then 'true' else 'false' end")
String guidExist(String guid);
@Query("Select case When :remoteId In (Select remoteId from Item) Then 1 else 0 end")
boolean remoteItemExists(int remoteId);
@Query("Select case When :remoteId In (Select remoteId from Item) And :feedId In (Select feed_id From Item) Then 1 else 0 end")
boolean remoteItemExists(int remoteId, int feedId);
@Insert
long insert(Item item);

View File

@ -192,12 +192,14 @@ public class NextNewsRepository extends ARepository {
for (NextNewsItem nextNewsItem : items) {
if (!initialSync) {
if (database.itemDao().remoteItemExists(nextNewsItem.getId()))
Feed feed = database.feedDao().getFeedByRemoteId(nextNewsItem.getFeedId(), account.getId());
if (!initialSync && feed != null) {
if (database.itemDao().remoteItemExists(nextNewsItem.getId(), feed.getId()))
break;
}
Feed feed = database.feedDao().getFeedByRemoteId(nextNewsItem.getFeedId(), account.getId());
Item item = ItemMatcher.nextNewsItemToItem(nextNewsItem, feed);
item.setReadTime(Utils.readTimeFromString(item.getContent()));