mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-07 08:39:30 +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.toMigrateCheck();
|
||||||
|
|
||||||
StatePlaylists.instance._historyDBStore.deleteAll();
|
StatePlaylists.instance._historyDBStore.deleteAll();
|
||||||
|
|
||||||
if(StatePlaylists.instance.shouldMigrateLegacyHistory())
|
if(StatePlaylists.instance.shouldMigrateLegacyHistory())
|
||||||
StatePlaylists.instance.migrateLegacyHistory();
|
StatePlaylists.instance.migrateLegacyHistory();
|
||||||
|
|
||||||
|
|
||||||
if(false) {
|
if(true) {
|
||||||
|
/*
|
||||||
Logger.i(TAG, "TEST:--------(200)---------");
|
Logger.i(TAG, "TEST:--------(200)---------");
|
||||||
testHistoryDB(200);
|
testHistoryDB(200);
|
||||||
Logger.i(TAG, "TEST:--------(1000)---------");
|
Logger.i(TAG, "TEST:--------(1000)---------");
|
||||||
|
@ -543,14 +545,19 @@ class StateApp {
|
||||||
testHistoryDB(4000);
|
testHistoryDB(4000);
|
||||||
Logger.i(TAG, "TEST:--------(6000)---------");
|
Logger.i(TAG, "TEST:--------(6000)---------");
|
||||||
testHistoryDB(6000);
|
testHistoryDB(6000);
|
||||||
|
*/
|
||||||
|
Logger.i(TAG, "TEST:--------(100000)---------");
|
||||||
|
scope.launch(Dispatchers.Default) {
|
||||||
|
testHistoryDB(100000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun testHistoryDB(count: Int) {
|
fun testHistoryDB(count: Int) {
|
||||||
Logger.i(TAG, "TEST: Starting tests");
|
Logger.i(TAG, "TEST: Starting tests");
|
||||||
StatePlaylists.instance._historyDBStore.deleteAll();
|
StatePlaylists.instance._historyDBStore.deleteAll();
|
||||||
|
|
||||||
val testHistoryItem = StatePlaylists.instance.getHistory().first();
|
val testHistoryItem = StatePlaylists.instance.getHistoryLegacy().first();
|
||||||
val testItemJson = StatePlaylists.instance.getHistory().first().video.toJson();
|
val testItemJson = testHistoryItem.video.toJson();
|
||||||
val now = OffsetDateTime.now();
|
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())) }
|
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);
|
StatePlaylists.instance._historyDBStore.insert(item);
|
||||||
};
|
};
|
||||||
Logger.i(TAG, "TEST: Inserting in ${insertMS}ms");
|
Logger.i(TAG, "TEST: Inserting in ${insertMS}ms");
|
||||||
|
/*
|
||||||
var fetched: List<DBHistory.Index>? = null;
|
var fetched: List<DBHistory.Index>? = null;
|
||||||
val fetchMS = measureTimeMillis {
|
val fetchMS = measureTimeMillis {
|
||||||
fetched = StatePlaylists.instance._historyDBStore.getAll();
|
fetched = StatePlaylists.instance._historyDBStore.getAll();
|
||||||
|
@ -574,7 +581,7 @@ class StateApp {
|
||||||
Logger.i(TAG, "TEST: Deserialized: ${deserialized.size}");
|
Logger.i(TAG, "TEST: Deserialized: ${deserialized.size}");
|
||||||
};
|
};
|
||||||
Logger.i(TAG, "TEST: Deserialize speed ${deserializeMS}MS");
|
Logger.i(TAG, "TEST: Deserialize speed ${deserializeMS}MS");
|
||||||
|
*/
|
||||||
var fetchedIndex: List<DBHistory.Index>? = null;
|
var fetchedIndex: List<DBHistory.Index>? = null;
|
||||||
val fetchIndexMS = measureTimeMillis {
|
val fetchIndexMS = measureTimeMillis {
|
||||||
fetchedIndex = StatePlaylists.instance._historyDBStore.getAllIndexes();
|
fetchedIndex = StatePlaylists.instance._historyDBStore.getAllIndexes();
|
||||||
|
|
|
@ -58,8 +58,7 @@ class StatePlaylists {
|
||||||
|
|
||||||
val historyIndex: ConcurrentMap<Any, DBHistory.Index> = ConcurrentHashMap();
|
val historyIndex: ConcurrentMap<Any, DBHistory.Index> = ConcurrentHashMap();
|
||||||
val _historyDBStore = ManagedDBStore.create("history", DBHistory.Descriptor())
|
val _historyDBStore = ManagedDBStore.create("history", DBHistory.Descriptor())
|
||||||
.withIndex({ it.url }, historyIndex)
|
.withIndex({ it.url }, historyIndex, true)
|
||||||
.withUnique({ it.url }, historyIndex)
|
|
||||||
.load();
|
.load();
|
||||||
|
|
||||||
val playlistShareDir = FragmentedStorage.getOrCreateDirectory("shares");
|
val playlistShareDir = FragmentedStorage.getOrCreateDirectory("shares");
|
||||||
|
@ -158,6 +157,9 @@ class StatePlaylists {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
fun getHistoryLegacy(): List<HistoryVideo> {
|
||||||
|
return _historyStore.getItems();
|
||||||
|
}
|
||||||
fun getHistory() : List<HistoryVideo> {
|
fun getHistory() : List<HistoryVideo> {
|
||||||
return _historyDBStore.getAllObjects();
|
return _historyDBStore.getAllObjects();
|
||||||
//return _historyStore.getItems().sortedByDescending { it.date };
|
//return _historyStore.getItems().sortedByDescending { it.date };
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.futo.platformplayer.stores.db
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
|
import androidx.room.migration.Migration
|
||||||
import androidx.sqlite.db.SimpleSQLiteQuery
|
import androidx.sqlite.db.SimpleSQLiteQuery
|
||||||
import com.futo.platformplayer.api.media.structures.AdhocPager
|
import com.futo.platformplayer.api.media.structures.AdhocPager
|
||||||
import com.futo.platformplayer.api.media.structures.IPager
|
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}]");
|
if(index.serialized == null) throw IllegalStateException("Cannot deserialize index-only items from [${name}]");
|
||||||
val obj = _serializer.deserialize(_class, index.serialized!!);
|
val obj = _serializer.deserialize(_class, index.serialized!!);
|
||||||
index.obj = obj;
|
index.obj = obj;
|
||||||
|
index.serialized = null;
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
fun deserializeIndexes(indexes: List<I>): List<I> {
|
fun deserializeIndexes(indexes: List<I>): List<I> {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.futo.platformplayer.*
|
import com.futo.platformplayer.*
|
||||||
|
import com.futo.platformplayer.api.media.structures.IPager
|
||||||
import com.futo.platformplayer.constructs.Event1
|
import com.futo.platformplayer.constructs.Event1
|
||||||
import com.futo.platformplayer.models.HistoryVideo
|
import com.futo.platformplayer.models.HistoryVideo
|
||||||
import com.futo.platformplayer.states.StateApp
|
import com.futo.platformplayer.states.StateApp
|
||||||
|
@ -45,6 +46,7 @@ class HistoryListAdapter : RecyclerView.Adapter<HistoryListViewHolder> {
|
||||||
|
|
||||||
fun updateFilteredVideos() {
|
fun updateFilteredVideos() {
|
||||||
val videos = StatePlaylists.instance.getHistory();
|
val videos = StatePlaylists.instance.getHistory();
|
||||||
|
|
||||||
if (_query.isBlank()) {
|
if (_query.isBlank()) {
|
||||||
_filteredVideos = videos.toMutableList();
|
_filteredVideos = videos.toMutableList();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue