Optimize the deletion of statistics data
This commit is contained in:
parent
5989d6daf6
commit
4289933155
|
@ -953,20 +953,7 @@ public class DBWriter {
|
||||||
return dbExec.submit(() -> {
|
return dbExec.submit(() -> {
|
||||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||||
adapter.open();
|
adapter.open();
|
||||||
|
adapter.resetAllMediaPlayedDuration();
|
||||||
List<Feed> feeds = DBReader.getFeedList();
|
|
||||||
for (Feed feed : feeds) {
|
|
||||||
List<FeedItem> items = DBReader.getFeed(feed.getId()).getItems();
|
|
||||||
for (FeedItem item : items) {
|
|
||||||
FeedMedia media = item.getMedia();
|
|
||||||
if (media == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
media.setPlayedDuration(0);
|
|
||||||
adapter.setFeedMediaPlaybackInformation(media);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
adapter.close();
|
adapter.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,6 +476,20 @@ public class PodDBAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetAllMediaPlayedDuration() {
|
||||||
|
try {
|
||||||
|
db.beginTransactionNonExclusive();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(KEY_PLAYED_DURATION, 0);
|
||||||
|
db.update(TABLE_NAME_FEED_MEDIA, values, null, new String[0]);
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
|
} finally {
|
||||||
|
db.endTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert all FeedItems of a feed and the feed object itself in a single
|
* Insert all FeedItems of a feed and the feed object itself in a single
|
||||||
* transaction
|
* transaction
|
||||||
|
|
Loading…
Reference in New Issue