Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint after re-enabling ktlint #19

Merged
merged 7 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class FeedDAO {
abstract fun deleteAll(): Int

@Query(
"""
"""
SELECT s.* FROM streams s

INNER JOIN feed f
Expand All @@ -29,11 +29,11 @@ abstract class FeedDAO {

LIMIT 500
"""
)
)
abstract fun getAllStreams(): Flowable<List<StreamEntity>>

@Query(
"""
"""
SELECT s.* FROM streams s

INNER JOIN feed f
Expand All @@ -50,11 +50,11 @@ abstract class FeedDAO {
ORDER BY s.upload_date IS NULL DESC, s.upload_date DESC, s.uploader ASC
LIMIT 500
"""
)
)
abstract fun getAllStreamsFromGroup(groupId: Long): Flowable<List<StreamEntity>>

@Query(
"""
"""
DELETE FROM feed WHERE

feed.stream_id IN (
Expand All @@ -66,11 +66,11 @@ abstract class FeedDAO {
WHERE s.upload_date < :date
)
"""
)
)
abstract fun unlinkStreamsOlderThan(date: Date)

@Query(
"""
"""
DELETE FROM feed

WHERE feed.subscription_id = :subscriptionId
Expand All @@ -84,7 +84,7 @@ abstract class FeedDAO {
WHERE s.stream_type = "LIVE_STREAM" OR s.stream_type = "AUDIO_LIVE_STREAM"
)
"""
)
)
abstract fun unlinkOldLivestreams(subscriptionId: Long)

@Insert(onConflict = OnConflictStrategy.IGNORE)
Expand All @@ -109,13 +109,13 @@ abstract class FeedDAO {
}

@Query(
"""
"""
SELECT MIN(lu.last_updated) FROM feed_last_updated lu

INNER JOIN feed_group_subscription_join fgs
ON fgs.subscription_id = lu.subscription_id AND fgs.group_id = :groupId
"""
)
)
abstract fun oldestSubscriptionUpdate(groupId: Long): Flowable<List<Date>>

@Query("SELECT MIN(last_updated) FROM feed_last_updated")
Expand All @@ -125,7 +125,7 @@ abstract class FeedDAO {
abstract fun notLoadedCount(): Flowable<Long>

@Query(
"""
"""
SELECT COUNT(*) FROM subscriptions s

INNER JOIN feed_group_subscription_join fgs
Expand All @@ -136,23 +136,23 @@ abstract class FeedDAO {

WHERE lu.last_updated IS NULL
"""
)
)
abstract fun notLoadedCountForGroup(groupId: Long): Flowable<Long>

@Query(
"""
"""
SELECT s.* FROM subscriptions s

LEFT JOIN feed_last_updated lu
ON s.uid = lu.subscription_id

WHERE lu.last_updated IS NULL OR lu.last_updated < :outdatedThreshold
"""
)
)
abstract fun getAllOutdated(outdatedThreshold: Date): Flowable<List<SubscriptionEntity>>

@Query(
"""
"""
SELECT s.* FROM subscriptions s

INNER JOIN feed_group_subscription_join fgs
Expand All @@ -163,6 +163,6 @@ abstract class FeedDAO {

WHERE lu.last_updated IS NULL OR lu.last_updated < :outdatedThreshold
"""
)
)
abstract fun getAllOutdatedForGroup(groupId: Long, outdatedThreshold: Date): Flowable<List<SubscriptionEntity>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import org.schabi.newpipelegacy.database.subscription.SubscriptionEntity
parentColumns = [StreamEntity.STREAM_ID],
childColumns = [STREAM_ID],
onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE, deferred = true
),
),
ForeignKey(
entity = SubscriptionEntity::class,
parentColumns = [SubscriptionEntity.SUBSCRIPTION_UID],
childColumns = [SUBSCRIPTION_ID],
onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE, deferred = true
)
)
]
)
data class FeedEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import org.schabi.newpipelegacy.database.subscription.SubscriptionEntity
parentColumns = [FeedGroupEntity.ID],
childColumns = [GROUP_ID],
onDelete = CASCADE, onUpdate = CASCADE, deferred = true
),
),

ForeignKey(
entity = SubscriptionEntity::class,
parentColumns = [SubscriptionEntity.SUBSCRIPTION_UID],
childColumns = [SUBSCRIPTION_ID],
onDelete = CASCADE, onUpdate = CASCADE, deferred = true
)
)
]
)
data class FeedGroupSubscriptionEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import java.util.Date
parentColumns = [SubscriptionEntity.SUBSCRIPTION_UID],
childColumns = [SUBSCRIPTION_ID],
onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE, deferred = true
)
)
]
)
data class FeedLastUpdatedEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import androidx.room.Embedded
import org.schabi.newpipe.extractor.stream.StreamInfoItem
import org.schabi.newpipelegacy.database.LocalItem
import org.schabi.newpipelegacy.database.playlist.model.PlaylistStreamEntity
import org.schabi.newpipelegacy.database.stream.model.StreamStateEntity
import org.schabi.newpipelegacy.database.stream.model.StreamEntity
import org.schabi.newpipelegacy.database.stream.model.StreamStateEntity
import kotlin.jvm.Throws

data class PlaylistStreamEntry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import androidx.room.Embedded
import org.schabi.newpipe.extractor.stream.StreamInfoItem
import org.schabi.newpipelegacy.database.LocalItem
import org.schabi.newpipelegacy.database.history.model.StreamHistoryEntity
import org.schabi.newpipelegacy.database.stream.model.StreamStateEntity.STREAM_PROGRESS_TIME
import org.schabi.newpipelegacy.database.stream.model.StreamEntity
import org.schabi.newpipelegacy.database.stream.model.StreamStateEntity.STREAM_PROGRESS_TIME
import java.util.Date

class StreamStatisticsEntry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
internal abstract fun silentInsertAllInternal(streams: List<StreamEntity>): List<Long>

@Query(
"""
"""
SELECT uid, stream_type, textual_upload_date, upload_date, is_upload_date_approximation, duration
FROM streams WHERE url = :url AND service_id = :serviceId
"""
)
)
internal abstract fun getMinimalStreamForCompare(serviceId: Int, url: String): StreamCompareFeed?

@Transaction
Expand Down Expand Up @@ -104,7 +104,7 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
}

@Query(
"""
"""
DELETE FROM streams WHERE

NOT EXISTS (SELECT 1 FROM stream_history sh
Expand All @@ -116,7 +116,7 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
AND NOT EXISTS (SELECT 1 FROM feed f
WHERE f.stream_id = streams.uid)
"""
)
)
abstract fun deleteOrphans(): Int

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ data class StreamEntity(
item.textualUploadDate = textualUploadDate
item.uploadDate = uploadDate?.let {
DateWrapper(
Calendar.getInstance().apply { time = it },
isUploadDateApproximation
?: false)
Calendar.getInstance().apply { time = it },
isUploadDateApproximation
?: false
)
}

return item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ abstract class SubscriptionDAO : BasicDAO<SubscriptionEntity> {
abstract override fun getAll(): Flowable<List<SubscriptionEntity>>

@Query(
"""
"""
SELECT * FROM subscriptions

WHERE name LIKE '%' || :filter || '%'

ORDER BY name COLLATE NOCASE ASC
"""
)
)
abstract fun getSubscriptionsFiltered(filter: String): Flowable<List<SubscriptionEntity>>

@Query(
"""
"""
SELECT * FROM subscriptions s

LEFT JOIN feed_group_subscription_join fgs
Expand All @@ -42,13 +42,13 @@ abstract class SubscriptionDAO : BasicDAO<SubscriptionEntity> {

ORDER BY name COLLATE NOCASE ASC
"""
)
)
abstract fun getSubscriptionsOnlyUngrouped(
currentGroupId: Long
): Flowable<List<SubscriptionEntity>>

@Query(
"""
"""
SELECT * FROM subscriptions s

LEFT JOIN feed_group_subscription_join fgs
Expand All @@ -59,7 +59,7 @@ abstract class SubscriptionDAO : BasicDAO<SubscriptionEntity> {

ORDER BY name COLLATE NOCASE ASC
"""
)
)
abstract fun getSubscriptionsOnlyUngroupedFiltered(
currentGroupId: Long,
filter: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {

if (loadedState.itemsErrors.isNotEmpty()) {
showSnackBarError(
loadedState.itemsErrors, UserAction.REQUESTED_FEED,
loadedState.itemsErrors, UserAction.REQUESTED_FEED,
"none", "Loading feed", R.string.general_error
)
)
}

if (loadedState.items.isEmpty()) {
Expand Down Expand Up @@ -308,10 +308,10 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {

private fun triggerUpdate() {
getActivity()?.startService(
Intent(requireContext(), FeedLoadService::class.java).apply {
Intent(requireContext(), FeedLoadService::class.java).apply {
putExtra(FeedLoadService.EXTRA_GROUP_ID, groupId)
}
)
)
listState = null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ class FeedViewModel(applicationContext: Context, val groupId: Long = FeedGroupEn
oldestUpdate?.let { Calendar.getInstance().apply { time = it } }

mutableStateLiveData.postValue(
when (event) {
when (event) {
is IdleEvent -> FeedState.LoadedState(listFromDB, oldestUpdateCalendar, notLoadedCount)
is ProgressEvent -> FeedState.ProgressState(event.currentProgress, event.maxProgress, event.progressMessage)
is SuccessResultEvent -> FeedState.LoadedState(listFromDB, oldestUpdateCalendar, notLoadedCount, event.itemsErrors)
is ErrorResultEvent -> FeedState.ErrorState(event.error)
}
)
)

if (event is ErrorResultEvent || event is SuccessResultEvent) {
FeedEventManager.reset()
Expand Down
Loading