-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from infinum/develop
Add history feature
- Loading branch information
Showing
85 changed files
with
1,423 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ctor/src/main/kotlin/com/infinum/dbinspector/data/models/local/proto/input/HistoryTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.infinum.dbinspector.data.models.local.proto.input | ||
|
||
import com.infinum.dbinspector.data.models.local.proto.output.HistoryEntity | ||
|
||
internal data class HistoryTask( | ||
val databasePath: String? = null, | ||
val execution: HistoryEntity.ExecutionEntity? = null, | ||
) |
13 changes: 13 additions & 0 deletions
13
dbinspector/src/main/kotlin/com/infinum/dbinspector/data/shared/base/BaseStore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.infinum.dbinspector.data.shared.base | ||
|
||
import androidx.datastore.core.DataStore | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
internal interface BaseStore<OutputModel> { | ||
|
||
suspend fun store(): DataStore<OutputModel> = throw NotImplementedError() | ||
|
||
suspend fun current(): OutputModel = throw NotImplementedError() | ||
|
||
fun flow(): Flow<OutputModel> = throw NotImplementedError() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
...ector/src/main/kotlin/com/infinum/dbinspector/data/source/local/proto/DataStoreFactory.kt
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...c/main/kotlin/com/infinum/dbinspector/data/source/local/proto/history/HistoryDataStore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.infinum.dbinspector.data.source.local.proto.history | ||
|
||
import androidx.datastore.core.DataStore | ||
import com.infinum.dbinspector.data.Sources | ||
import com.infinum.dbinspector.data.models.local.proto.output.HistoryEntity | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.firstOrNull | ||
|
||
internal class HistoryDataStore( | ||
private val store: DataStore<HistoryEntity> | ||
) : Sources.Local.History { | ||
|
||
override suspend fun store(): DataStore<HistoryEntity> = store | ||
|
||
override suspend fun current(): HistoryEntity = | ||
store.data.firstOrNull() ?: HistoryEntity.getDefaultInstance() | ||
|
||
override fun flow(): Flow<HistoryEntity> = | ||
store.data | ||
} |
25 changes: 25 additions & 0 deletions
25
.../main/kotlin/com/infinum/dbinspector/data/source/local/proto/history/HistorySerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.infinum.dbinspector.data.source.local.proto.history | ||
|
||
import androidx.datastore.core.CorruptionException | ||
import androidx.datastore.core.Serializer | ||
import com.google.protobuf.InvalidProtocolBufferException | ||
import com.infinum.dbinspector.data.models.local.proto.output.HistoryEntity | ||
import java.io.InputStream | ||
import java.io.OutputStream | ||
|
||
internal class HistorySerializer : Serializer<HistoryEntity> { | ||
|
||
override val defaultValue: HistoryEntity = | ||
HistoryEntity.getDefaultInstance() | ||
|
||
override fun readFrom(input: InputStream): HistoryEntity { | ||
try { | ||
return HistoryEntity.parseFrom(input) | ||
} catch (exception: InvalidProtocolBufferException) { | ||
throw CorruptionException("Cannot read proto.", exception) | ||
} | ||
} | ||
|
||
override fun writeTo(t: HistoryEntity, output: OutputStream) = | ||
t.writeTo(output) | ||
} |
20 changes: 20 additions & 0 deletions
20
...main/kotlin/com/infinum/dbinspector/data/source/local/proto/settings/SettingsDataStore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.infinum.dbinspector.data.source.local.proto.settings | ||
|
||
import androidx.datastore.core.DataStore | ||
import com.infinum.dbinspector.data.Sources | ||
import com.infinum.dbinspector.data.models.local.proto.output.SettingsEntity | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.firstOrNull | ||
|
||
internal class SettingsDataStore( | ||
private val store: DataStore<SettingsEntity> | ||
) : Sources.Local.Settings { | ||
|
||
override suspend fun store(): DataStore<SettingsEntity> = store | ||
|
||
override suspend fun current(): SettingsEntity = | ||
store.data.firstOrNull() ?: SettingsEntity.getDefaultInstance() | ||
|
||
override fun flow(): Flow<SettingsEntity> = | ||
store.data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.