Skip to content
Permalink
Browse files

Move to using Trakt's last_updated_at field

  • Loading branch information...
chrisbanes committed Jun 26, 2019
1 parent bf2510f commit 735dd39e6995cc7cbb2dd7dda43785a708c92923
@@ -25,5 +25,10 @@ import javax.inject.Singleton
class TraktBaseShowToTiviShow @Inject constructor(
private val showMapper: TraktShowToTiviShow
) : Mapper<BaseShow, TiviShow> {
override suspend fun map(from: BaseShow) = showMapper.map(from.show)
override suspend fun map(from: BaseShow): TiviShow {
val mapped = showMapper.map(from.show)
return mapped.copy(
traktDataUpdate = from.last_updated_at ?: mapped.traktDataUpdate
)
}
}
@@ -16,6 +16,7 @@

package app.tivi.data.repositories.shows

import app.tivi.data.entities.TiviShow
import app.tivi.data.instantInPast
import app.tivi.data.resultentities.ShowDetailed
import io.reactivex.Observable
@@ -29,7 +30,7 @@ interface ShowRepository {
/**
* Updates the show with the given id from all network sources, saves the result to the database
*/
suspend fun getShow(showId: Long): ShowDetailed
suspend fun getShow(showId: Long): TiviShow?

/**
* Updates the show with the given id from all network sources, saves the result to the database
@@ -35,11 +35,8 @@ class ShowRepositoryImpl @Inject constructor(
) : ShowRepository {
override fun observeShow(showId: Long) = showStore.observeShowDetailed(showId)

/**
* Updates the show with the given id from all network sources, saves the result to the database
*/
override suspend fun getShow(showId: Long): ShowDetailed {
return showStore.getShowDetailed(showId)!!
override suspend fun getShow(showId: Long): TiviShow? {
return showStore.getShow(showId)
}

/**
@@ -20,6 +20,7 @@ import app.tivi.data.entities.RefreshType
import app.tivi.data.instantInPast
import app.tivi.data.repositories.episodes.SeasonsEpisodesRepository
import app.tivi.data.repositories.followedshows.FollowedShowsRepository
import app.tivi.data.repositories.shows.ShowRepository
import app.tivi.data.repositories.watchedshows.WatchedShowsRepository
import app.tivi.extensions.parallelForEach
import app.tivi.util.AppCoroutineDispatchers
@@ -30,6 +31,7 @@ import javax.inject.Inject

class UpdateFollowedShows @Inject constructor(
dispatchers: AppCoroutineDispatchers,
private val showRepository: ShowRepository,
private val followedShowsRepository: FollowedShowsRepository,
private val watchedShowsRepository: WatchedShowsRepository,
private val seasonEpisodeRepository: SeasonsEpisodesRepository
@@ -63,9 +65,7 @@ class UpdateFollowedShows @Inject constructor(
it.showId,
params.type,
params.forceRefresh,
// TODO: We should use last_updated_at. Waiting on trakt-java support in
// https://github.com/UweTrottmann/trakt-java/pull/106
watchedShowsRepository.getWatchedShow(it.showId)?.lastWatched
showRepository.getShow(it.showId)?.traktDataUpdate
)
}
}

0 comments on commit 735dd39

Please sign in to comment.
You can’t perform that action at this time.