From 37ceddd11b7260055ed525b43ce86111a47dfe3b Mon Sep 17 00:00:00 2001 From: vkay94 Date: Sun, 15 Nov 2020 14:08:41 +0100 Subject: [PATCH] Add progressTime field to some stream entries (database) --- .../database/history/dao/StreamHistoryDAO.java | 11 ++++++++++- .../database/playlist/PlaylistStreamEntry.kt | 4 ++++ .../database/playlist/dao/PlaylistStreamDAO.java | 10 ++++++++++ .../database/stream/StreamStatisticsEntry.kt | 14 +++++++++----- .../database/stream/model/StreamStateEntity.java | 3 +++ 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.java b/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.java index c716a2d91..8a9cab182 100644 --- a/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.java +++ b/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.java @@ -20,6 +20,9 @@ import static org.schabi.newpipe.database.stream.StreamStatisticsEntry.STREAM_LA import static org.schabi.newpipe.database.stream.StreamStatisticsEntry.STREAM_WATCH_COUNT; import static org.schabi.newpipe.database.stream.model.StreamEntity.STREAM_ID; import static org.schabi.newpipe.database.stream.model.StreamEntity.STREAM_TABLE; +import static org.schabi.newpipe.database.stream.model.StreamStateEntity.JOIN_STREAM_ID_ALIAS; +import static org.schabi.newpipe.database.stream.model.StreamStateEntity.STREAM_PROGRESS_TIME; +import static org.schabi.newpipe.database.stream.model.StreamStateEntity.STREAM_STATE_TABLE; @Dao public abstract class StreamHistoryDAO implements HistoryDAO { @@ -73,6 +76,12 @@ public abstract class StreamHistoryDAO implements HistoryDAO { @@ -58,6 +61,13 @@ public abstract class PlaylistStreamDAO implements BasicDAO> getOrderedStreamsOf(long playlistId); diff --git a/app/src/main/java/org/schabi/newpipe/database/stream/StreamStatisticsEntry.kt b/app/src/main/java/org/schabi/newpipe/database/stream/StreamStatisticsEntry.kt index 1e4c672ab..eca12f584 100644 --- a/app/src/main/java/org/schabi/newpipe/database/stream/StreamStatisticsEntry.kt +++ b/app/src/main/java/org/schabi/newpipe/database/stream/StreamStatisticsEntry.kt @@ -2,23 +2,27 @@ package org.schabi.newpipe.database.stream import androidx.room.ColumnInfo import androidx.room.Embedded -import java.time.OffsetDateTime import org.schabi.newpipe.database.LocalItem import org.schabi.newpipe.database.history.model.StreamHistoryEntity import org.schabi.newpipe.database.stream.model.StreamEntity +import org.schabi.newpipe.database.stream.model.StreamStateEntity.STREAM_PROGRESS_TIME import org.schabi.newpipe.extractor.stream.StreamInfoItem +import java.time.OffsetDateTime class StreamStatisticsEntry( - @Embedded + @Embedded val streamEntity: StreamEntity, - @ColumnInfo(name = StreamHistoryEntity.JOIN_STREAM_ID) + @ColumnInfo(name = STREAM_PROGRESS_TIME, defaultValue = "0") + val progressTime: Long, + + @ColumnInfo(name = StreamHistoryEntity.JOIN_STREAM_ID) val streamId: Long, - @ColumnInfo(name = STREAM_LATEST_DATE) + @ColumnInfo(name = STREAM_LATEST_DATE) val latestAccessDate: OffsetDateTime, - @ColumnInfo(name = STREAM_WATCH_COUNT) + @ColumnInfo(name = STREAM_WATCH_COUNT) val watchCount: Long ) : LocalItem { fun toStreamInfoItem(): StreamInfoItem { diff --git a/app/src/main/java/org/schabi/newpipe/database/stream/model/StreamStateEntity.java b/app/src/main/java/org/schabi/newpipe/database/stream/model/StreamStateEntity.java index d275d9a71..1ce834a82 100644 --- a/app/src/main/java/org/schabi/newpipe/database/stream/model/StreamStateEntity.java +++ b/app/src/main/java/org/schabi/newpipe/database/stream/model/StreamStateEntity.java @@ -22,6 +22,9 @@ import static org.schabi.newpipe.database.stream.model.StreamStateEntity.STREAM_ public class StreamStateEntity { public static final String STREAM_STATE_TABLE = "stream_state"; public static final String JOIN_STREAM_ID = "stream_id"; + // This additional field is required for the SQL query because 'stream_id' is used + // for some other joins already + public static final String JOIN_STREAM_ID_ALIAS = "stream_id_alias"; public static final String STREAM_PROGRESS_TIME = "progress_time"; /**