mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
WIP
This commit is contained in:
parent
b65fc594dc
commit
869789f0e2
4 changed files with 20 additions and 7 deletions
|
@ -528,11 +528,13 @@ class StateApp {
|
|||
StatePlaylists.instance.toMigrateCheck();
|
||||
|
||||
StatePlaylists.instance._historyDBStore.deleteAll();
|
||||
|
||||
if(StatePlaylists.instance.shouldMigrateLegacyHistory())
|
||||
StatePlaylists.instance.migrateLegacyHistory();
|
||||
|
||||
|
||||
if(false) {
|
||||
if(true) {
|
||||
/*
|
||||
Logger.i(TAG, "TEST:--------(200)---------");
|
||||
testHistoryDB(200);
|
||||
Logger.i(TAG, "TEST:--------(1000)---------");
|
||||
|
@ -543,14 +545,19 @@ class StateApp {
|
|||
testHistoryDB(4000);
|
||||
Logger.i(TAG, "TEST:--------(6000)---------");
|
||||
testHistoryDB(6000);
|
||||
*/
|
||||
Logger.i(TAG, "TEST:--------(100000)---------");
|
||||
scope.launch(Dispatchers.Default) {
|
||||
testHistoryDB(100000);
|
||||
}
|
||||
}
|
||||
}
|
||||
fun testHistoryDB(count: Int) {
|
||||
Logger.i(TAG, "TEST: Starting tests");
|
||||
StatePlaylists.instance._historyDBStore.deleteAll();
|
||||
|
||||
val testHistoryItem = StatePlaylists.instance.getHistory().first();
|
||||
val testItemJson = StatePlaylists.instance.getHistory().first().video.toJson();
|
||||
val testHistoryItem = StatePlaylists.instance.getHistoryLegacy().first();
|
||||
val testItemJson = testHistoryItem.video.toJson();
|
||||
val now = OffsetDateTime.now();
|
||||
|
||||
val testSet = (0..count).map { HistoryVideo(Json.decodeFromString<SerializedPlatformVideo>(testItemJson.replace(testHistoryItem.video.url, UUID.randomUUID().toString())), it.toLong(), now.minusHours(it.toLong())) }
|
||||
|
@ -562,7 +569,7 @@ class StateApp {
|
|||
StatePlaylists.instance._historyDBStore.insert(item);
|
||||
};
|
||||
Logger.i(TAG, "TEST: Inserting in ${insertMS}ms");
|
||||
|
||||
/*
|
||||
var fetched: List<DBHistory.Index>? = null;
|
||||
val fetchMS = measureTimeMillis {
|
||||
fetched = StatePlaylists.instance._historyDBStore.getAll();
|
||||
|
@ -574,7 +581,7 @@ class StateApp {
|
|||
Logger.i(TAG, "TEST: Deserialized: ${deserialized.size}");
|
||||
};
|
||||
Logger.i(TAG, "TEST: Deserialize speed ${deserializeMS}MS");
|
||||
|
||||
*/
|
||||
var fetchedIndex: List<DBHistory.Index>? = null;
|
||||
val fetchIndexMS = measureTimeMillis {
|
||||
fetchedIndex = StatePlaylists.instance._historyDBStore.getAllIndexes();
|
||||
|
|
|
@ -58,8 +58,7 @@ class StatePlaylists {
|
|||
|
||||
val historyIndex: ConcurrentMap<Any, DBHistory.Index> = ConcurrentHashMap();
|
||||
val _historyDBStore = ManagedDBStore.create("history", DBHistory.Descriptor())
|
||||
.withIndex({ it.url }, historyIndex)
|
||||
.withUnique({ it.url }, historyIndex)
|
||||
.withIndex({ it.url }, historyIndex, true)
|
||||
.load();
|
||||
|
||||
val playlistShareDir = FragmentedStorage.getOrCreateDirectory("shares");
|
||||
|
@ -158,6 +157,9 @@ class StatePlaylists {
|
|||
}
|
||||
}
|
||||
*/
|
||||
fun getHistoryLegacy(): List<HistoryVideo> {
|
||||
return _historyStore.getItems();
|
||||
}
|
||||
fun getHistory() : List<HistoryVideo> {
|
||||
return _historyDBStore.getAllObjects();
|
||||
//return _historyStore.getItems().sortedByDescending { it.date };
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.futo.platformplayer.stores.db
|
|||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Room
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SimpleSQLiteQuery
|
||||
import com.futo.platformplayer.api.media.structures.AdhocPager
|
||||
import com.futo.platformplayer.api.media.structures.IPager
|
||||
|
@ -241,6 +242,7 @@ class ManagedDBStore<I: ManagedDBIndex<T>, T, D: ManagedDBDatabase<T, I, DA>, DA
|
|||
if(index.serialized == null) throw IllegalStateException("Cannot deserialize index-only items from [${name}]");
|
||||
val obj = _serializer.deserialize(_class, index.serialized!!);
|
||||
index.obj = obj;
|
||||
index.serialized = null;
|
||||
return index;
|
||||
}
|
||||
fun deserializeIndexes(indexes: List<I>): List<I> {
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.view.LayoutInflater
|
|||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.futo.platformplayer.*
|
||||
import com.futo.platformplayer.api.media.structures.IPager
|
||||
import com.futo.platformplayer.constructs.Event1
|
||||
import com.futo.platformplayer.models.HistoryVideo
|
||||
import com.futo.platformplayer.states.StateApp
|
||||
|
@ -45,6 +46,7 @@ class HistoryListAdapter : RecyclerView.Adapter<HistoryListViewHolder> {
|
|||
|
||||
fun updateFilteredVideos() {
|
||||
val videos = StatePlaylists.instance.getHistory();
|
||||
|
||||
if (_query.isBlank()) {
|
||||
_filteredVideos = videos.toMutableList();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue