mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-05-09 19:14:38 +02:00
Cleanup on store PR.
This commit is contained in:
parent
aee5b75c2f
commit
c5d35b27f0
@ -553,27 +553,6 @@ class StateApp {
|
|||||||
|
|
||||||
if(StateHistory.instance.shouldMigrateLegacyHistory())
|
if(StateHistory.instance.shouldMigrateLegacyHistory())
|
||||||
StateHistory.instance.migrateLegacyHistory();
|
StateHistory.instance.migrateLegacyHistory();
|
||||||
|
|
||||||
|
|
||||||
if(false) {
|
|
||||||
/*
|
|
||||||
Logger.i(TAG, "TEST:--------(200)---------");
|
|
||||||
testHistoryDB(200);
|
|
||||||
Logger.i(TAG, "TEST:--------(1000)---------");
|
|
||||||
testHistoryDB(1000);
|
|
||||||
Logger.i(TAG, "TEST:--------(2000)---------");
|
|
||||||
testHistoryDB(2000);
|
|
||||||
Logger.i(TAG, "TEST:--------(4000)---------");
|
|
||||||
testHistoryDB(4000);
|
|
||||||
Logger.i(TAG, "TEST:--------(6000)---------");
|
|
||||||
testHistoryDB(6000);
|
|
||||||
Logger.i(TAG, "TEST:--------(100000)---------");
|
|
||||||
scope.launch(Dispatchers.Default) {
|
|
||||||
StateHistory.instance.testHistoryDB(100000);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mainAppStartedWithExternalFiles(context: Context) {
|
fun mainAppStartedWithExternalFiles(context: Context) {
|
||||||
|
@ -39,27 +39,16 @@ class StateCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getChannelCachePager(channelUrl: String): IPager<IPlatformContent> {
|
fun getChannelCachePager(channelUrl: String): IPager<IPlatformContent> {
|
||||||
val result: IPager<IPlatformContent>;
|
return _subscriptionCache.queryPager(DBSubscriptionCache.Index::channelUrl, channelUrl, 20) { it.obj }
|
||||||
val time = measureTimeMillis {
|
|
||||||
result = _subscriptionCache.queryPager(DBSubscriptionCache.Index::channelUrl, channelUrl, 20) {
|
|
||||||
it.obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
fun getAllChannelCachePager(channelUrls: List<String>): IPager<IPlatformContent> {
|
fun getAllChannelCachePager(channelUrls: List<String>): IPager<IPlatformContent> {
|
||||||
val result: IPager<IPlatformContent>;
|
return _subscriptionCache.queryInPager(DBSubscriptionCache.Index::channelUrl, channelUrls, 20) { it.obj }
|
||||||
val time = measureTimeMillis {
|
}
|
||||||
result = _subscriptionCache.queryInPager(DBSubscriptionCache.Index::channelUrl, channelUrls, 20) {
|
|
||||||
|
fun getChannelCachePager(channelUrls: List<String>, pageSize: Int = 20): IPager<IPlatformContent> {
|
||||||
|
val pagers = MultiChronoContentPager(channelUrls.map { _subscriptionCache.queryPager(DBSubscriptionCache.Index::channelUrl, it, pageSize) {
|
||||||
it.obj;
|
it.obj;
|
||||||
}
|
} }, false, pageSize);
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
fun getChannelCachePager(channelUrls: List<String>): IPager<IPlatformContent> {
|
|
||||||
val pagers = MultiChronoContentPager(channelUrls.map { _subscriptionCache.queryPager(DBSubscriptionCache.Index::channelUrl, it, 20) {
|
|
||||||
it.obj;
|
|
||||||
} }, false, 20);
|
|
||||||
return DedupContentPager(pagers, StatePlatform.instance.getEnabledClients().map { it.id });
|
return DedupContentPager(pagers, StatePlatform.instance.getEnabledClients().map { it.id });
|
||||||
}
|
}
|
||||||
fun getSubscriptionCachePager(): DedupContentPager {
|
fun getSubscriptionCachePager(): DedupContentPager {
|
||||||
@ -79,13 +68,6 @@ class StateCache {
|
|||||||
|
|
||||||
val timeCacheRetrieving = measureTimeMillis {
|
val timeCacheRetrieving = measureTimeMillis {
|
||||||
pagers = listOf(getAllChannelCachePager(allUrls));
|
pagers = listOf(getAllChannelCachePager(allUrls));
|
||||||
|
|
||||||
/*allUrls.parallelStream()
|
|
||||||
.map {
|
|
||||||
getChannelCachePager(it)
|
|
||||||
}
|
|
||||||
.asSequence()
|
|
||||||
.toList();*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.i(TAG, "Subscriptions CachePager compiling (retrieved in ${timeCacheRetrieving}ms)");
|
Logger.i(TAG, "Subscriptions CachePager compiling (retrieved in ${timeCacheRetrieving}ms)");
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
package com.futo.platformplayer.stores.db
|
|
||||||
|
|
||||||
import androidx.room.Dao
|
|
||||||
import androidx.room.Delete
|
|
||||||
import androidx.room.Insert
|
|
||||||
import androidx.room.Query
|
|
||||||
import androidx.room.Update
|
|
||||||
|
|
||||||
/*
|
|
||||||
@Dao
|
|
||||||
class ManagedDBContext<T, I: ManagedDBIndex<T>> {
|
|
||||||
|
|
||||||
fun get(id: Int): I;
|
|
||||||
fun gets(vararg id: Int): List<I>;
|
|
||||||
fun getAll(): List<I>;
|
|
||||||
|
|
||||||
@Insert
|
|
||||||
fun insert(index: I);
|
|
||||||
@Insert
|
|
||||||
fun insertAll(vararg indexes: I)
|
|
||||||
|
|
||||||
@Update
|
|
||||||
fun update(index: I);
|
|
||||||
|
|
||||||
@Delete
|
|
||||||
fun delete(index: I);
|
|
||||||
}*/
|
|
@ -1,42 +1,23 @@
|
|||||||
package com.futo.platformplayer.subscription
|
package com.futo.platformplayer.subscription
|
||||||
|
|
||||||
import com.futo.platformplayer.api.media.models.contents.IPlatformContent
|
|
||||||
import com.futo.platformplayer.api.media.platforms.js.JSClient
|
import com.futo.platformplayer.api.media.platforms.js.JSClient
|
||||||
import com.futo.platformplayer.api.media.structures.DedupContentPager
|
import com.futo.platformplayer.api.media.structures.DedupContentPager
|
||||||
import com.futo.platformplayer.api.media.structures.IPager
|
|
||||||
import com.futo.platformplayer.api.media.structures.PlatformContentPager
|
|
||||||
import com.futo.platformplayer.models.Subscription
|
import com.futo.platformplayer.models.Subscription
|
||||||
import com.futo.platformplayer.polycentric.PolycentricCache
|
|
||||||
import com.futo.platformplayer.resolveChannelUrl
|
|
||||||
import com.futo.platformplayer.states.StateCache
|
import com.futo.platformplayer.states.StateCache
|
||||||
import com.futo.platformplayer.states.StatePlatform
|
import com.futo.platformplayer.states.StatePlatform
|
||||||
import com.futo.platformplayer.states.StateSubscriptions
|
|
||||||
import com.futo.platformplayer.toSafeFileName
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import java.util.concurrent.ForkJoinPool
|
import java.util.concurrent.ForkJoinPool
|
||||||
|
|
||||||
class CachedSubscriptionAlgorithm(pageSize: Int = 150, scope: CoroutineScope, allowFailure: Boolean = false, withCacheFallback: Boolean = true, threadPool: ForkJoinPool? = null)
|
class CachedSubscriptionAlgorithm(scope: CoroutineScope, allowFailure: Boolean = false, withCacheFallback: Boolean = true, threadPool: ForkJoinPool? = null, pageSize: Int = 50)
|
||||||
: SubscriptionFetchAlgorithm(scope, allowFailure, withCacheFallback, threadPool) {
|
: SubscriptionFetchAlgorithm(scope, allowFailure, withCacheFallback, threadPool) {
|
||||||
|
|
||||||
private val _pageSize: Int = pageSize;
|
private val _pageSize: Int = pageSize;
|
||||||
|
|
||||||
override fun countRequests(subs: Map<Subscription, List<String>>): Map<JSClient, Int> {
|
override fun countRequests(subs: Map<Subscription, List<String>>): Map<JSClient, Int> {
|
||||||
return mapOf<JSClient, Int>();
|
return mapOf();
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSubscriptions(subs: Map<Subscription, List<String>>): Result {
|
override fun getSubscriptions(subs: Map<Subscription, List<String>>): Result {
|
||||||
val validSubIds = subs.flatMap { it.value } .map { it.toSafeFileName() }.toHashSet();
|
return Result(DedupContentPager(StateCache.instance.getChannelCachePager(subs.flatMap { it.value }.distinct(), _pageSize), StatePlatform.instance.getEnabledClients().map { it.id }), listOf());
|
||||||
|
|
||||||
/*
|
|
||||||
val validStores = StateCache.instance._channelContents
|
|
||||||
.filter { validSubIds.contains(it.key) }
|
|
||||||
.map { it.value };*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
val items = validStores.flatMap { it.getItems() }
|
|
||||||
.sortedByDescending { it.datetime };
|
|
||||||
*/
|
|
||||||
|
|
||||||
return Result(DedupContentPager(StateCache.instance.getChannelCachePager(subs.flatMap { it.value }.distinct()), StatePlatform.instance.getEnabledClients().map { it.id }), listOf());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,7 +38,7 @@ abstract class SubscriptionFetchAlgorithm(
|
|||||||
|
|
||||||
fun getAlgorithm(algo: SubscriptionFetchAlgorithms, scope: CoroutineScope, allowFailure: Boolean = false, withCacheFallback: Boolean = false, pool: ForkJoinPool? = null): SubscriptionFetchAlgorithm {
|
fun getAlgorithm(algo: SubscriptionFetchAlgorithms, scope: CoroutineScope, allowFailure: Boolean = false, withCacheFallback: Boolean = false, pool: ForkJoinPool? = null): SubscriptionFetchAlgorithm {
|
||||||
return when(algo) {
|
return when(algo) {
|
||||||
SubscriptionFetchAlgorithms.CACHE -> CachedSubscriptionAlgorithm(150, scope, allowFailure, withCacheFallback, pool);
|
SubscriptionFetchAlgorithms.CACHE -> CachedSubscriptionAlgorithm(scope, allowFailure, withCacheFallback, pool, 50);
|
||||||
SubscriptionFetchAlgorithms.SIMPLE -> SimpleSubscriptionAlgorithm(scope, allowFailure, withCacheFallback, pool);
|
SubscriptionFetchAlgorithms.SIMPLE -> SimpleSubscriptionAlgorithm(scope, allowFailure, withCacheFallback, pool);
|
||||||
SubscriptionFetchAlgorithms.SMART -> SmartSubscriptionAlgorithm(scope, allowFailure, withCacheFallback, pool);
|
SubscriptionFetchAlgorithms.SMART -> SmartSubscriptionAlgorithm(scope, allowFailure, withCacheFallback, pool);
|
||||||
else -> throw IllegalStateException("Unknown algorithm ${algo}");
|
else -> throw IllegalStateException("Unknown algorithm ${algo}");
|
||||||
|
@ -47,8 +47,7 @@ class HistoryListAdapter : RecyclerView.Adapter<HistoryListViewHolder> {
|
|||||||
|
|
||||||
fun updateFilteredVideos() {
|
fun updateFilteredVideos() {
|
||||||
val videos = StateHistory.instance.getHistory();
|
val videos = StateHistory.instance.getHistory();
|
||||||
val pager = StateHistory.instance.getHistoryPager();
|
//filtered val pager = StateHistory.instance.getHistorySearchPager("querrryyyyy"); TODO: Implement pager
|
||||||
//filtered val pager = StateHistory.instance.getHistorySearchPager("querrryyyyy");
|
|
||||||
|
|
||||||
if (_query.isBlank()) {
|
if (_query.isBlank()) {
|
||||||
_filteredVideos = videos.toMutableList();
|
_filteredVideos = videos.toMutableList();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user