Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
1 result

Target

Select target project
  • justJanne/meteroid
1 result
Select Git revision
  • main
1 result
Show changes
Showing
with 738 additions and 78 deletions
/*
* The MIT License (MIT)
*
* Copyright (c) 2013-2023 Chaosdorf e.V.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.chaosdorf.meteroid.ui.wrapped
import de.chaosdorf.mete.model.DrinkId
import de.chaosdorf.meteroid.model.Drink
import de.chaosdorf.meteroid.model.Transaction
import kotlinx.datetime.DayOfWeek
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
sealed class WrappedSlide {
interface Factory {
fun create(
transactions: List<Transaction>,
drinks: Map<DrinkId, Drink>
): WrappedSlide?
}
data class MostBoughtDrink(
val drink: Drink,
val count: Int,
) : WrappedSlide() {
companion object : Factory {
override fun create(
transactions: List<Transaction>,
drinks: Map<DrinkId, Drink>
): WrappedSlide? = transactions
.mapNotNull { drinks[it.drinkId] }
.groupingBy { it }
.eachCount()
.maxByOrNull { it.value }
?.let { (mostBoughtDrink, count) ->
MostBoughtDrink(mostBoughtDrink, count)
}
}
}
data class Caffeine(
val total: Double,
val wouldKill: Animal?,
) : WrappedSlide() {
enum class Animal(val lethalDosage: Double) {
Hamster(0.25),
Squirrel(0.3),
Rat(0.4),
GuineaPig(0.9),
Lemur(2.5),
Cat(5.0),
Koala(9.0),
Coyote(13.0),
Lynx(23.0),
Capybara(55.0),
Jaguar(81.0),
Reindeer(101.0),
Gorilla(140.0),
Lion(175.0),
Bear(278.0),
Moose(368.0),
Bison(540.0)
}
companion object : Factory {
override fun create(
transactions: List<Transaction>,
drinks: Map<DrinkId, Drink>
): WrappedSlide = transactions
.mapNotNull { drinks[it.drinkId] }
.mapNotNull { drink -> drink.caffeine?.let { it * drink.volume.toDouble() * 10 } }
.sum()
.let { dosage ->
Caffeine(
dosage,
Animal.values()
.sortedBy(Animal::lethalDosage)
.firstOrNull { it.lethalDosage < dosage }
)
}
}
}
data class MostActive(
val weekday: DayOfWeek,
val hour: Int,
) : WrappedSlide() {
companion object : Factory {
override fun create(
transactions: List<Transaction>,
drinks: Map<DrinkId, Drink>
): WrappedSlide = transactions
.map { it.timestamp.toLocalDateTime(TimeZone.currentSystemDefault()) }
.groupingBy { Pair(it.dayOfWeek, it.hour) }
.eachCount()
.maxBy { it.value }
.key
.let { (dayOfWeek, hour) ->
MostActive(dayOfWeek, hour)
}
}
}
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2013-2023 Chaosdorf e.V.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.chaosdorf.meteroid.ui.wrapped
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import de.chaosdorf.mete.model.DrinkId
import de.chaosdorf.meteroid.model.AccountInfo
import de.chaosdorf.meteroid.model.Drink
import de.chaosdorf.meteroid.model.DrinkRepository
import de.chaosdorf.meteroid.model.Server
import de.chaosdorf.meteroid.model.TransactionRepository
import de.chaosdorf.meteroid.sync.AccountProvider
import de.chaosdorf.meteroid.sync.SyncManager
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.Month
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toInstant
import kotlinx.datetime.toLocalDateTime
import javax.inject.Inject
@HiltViewModel
class WrappedViewModel @Inject constructor(
private val accountProvider: AccountProvider,
repository: TransactionRepository,
drinkRepository: DrinkRepository,
private val syncManager: SyncManager
) : ViewModel() {
val account: StateFlow<AccountInfo?> = accountProvider.account
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
val slides: StateFlow<List<WrappedSlide>> = accountProvider.account
.flatMapLatest { account ->
account?.let { (server, maybeUser) ->
maybeUser?.let { user ->
combine(
repository.getAllFlow(server.serverId, user.userId),
drinkRepository.getAllFlow(server.serverId)
) { transactions, drinks ->
val drinkMap: Map<DrinkId, Drink> = drinks.associateBy(Drink::drinkId)
val factories = listOf(
WrappedSlide.MostBoughtDrink,
WrappedSlide.Caffeine,
WrappedSlide.MostActive
)
val timeZone = TimeZone.currentSystemDefault()
val now = Clock.System.now().toLocalDateTime(timeZone)
val yearBegin = LocalDateTime(
year = now.year,
month = Month.JANUARY,
dayOfMonth = 1,
hour = 0,
minute = 0,
second = 0
).toInstant(timeZone)
val yearEnd = LocalDateTime(
year = now.year + 1,
month = Month.JANUARY,
dayOfMonth = 1,
hour = 0,
minute = 0,
second = 0
).toInstant(timeZone)
val thisYear = transactions.filter {
it.timestamp in yearBegin..yearEnd
}
factories.mapNotNull { it.create(thisYear, drinkMap) }
}
}
} ?: flowOf(emptyList())
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), emptyList())
fun togglePin() {
account.value?.let { account ->
account.user?.let { user ->
viewModelScope.launch {
accountProvider.togglePin(account.server.serverId, user.userId)
}
}
}
}
suspend fun checkOffline(server: Server?): Boolean =
if (server == null) true
else syncManager.checkOffline(server)
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2013-2023 Chaosdorf e.V.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.chaosdorf.meteroid.util
import de.chaosdorf.mete.model.MeteApiFactory
import de.chaosdorf.meteroid.model.Server
import de.chaosdorf.meteroid.model.ServerId
import java.net.URI
suspend fun MeteApiFactory.newServer(serverId: ServerId, baseUrl: String): Server? = try {
val api = newInstance(baseUrl)
val manifest = api.getManifest()
val icon = manifest?.icons?.maxByOrNull {
it.sizes?.split("x")
?.mapNotNull(String::toIntOrNull)
?.reduce(Int::times)
?: 0
}
val iconUrl = icon?.src?.let { URI(baseUrl).resolve(it).toString() }
Server(
serverId,
manifest?.name,
baseUrl,
iconUrl
)
} catch (_: Exception) {
null
}
......@@ -24,13 +24,12 @@
package de.chaosdorf.meteroid.util
import de.chaosdorf.mete.PwaIcon
import de.chaosdorf.mete.PwaManifest
import okhttp3.HttpUrl.Companion.toHttpUrl
import androidx.lifecycle.SavedStateHandle
fun PwaManifest.findBestIcon(): PwaIcon? = icons.maxByOrNull {
it.sizes?.split("x")?.firstOrNull()?.toIntOrNull() ?: 0
fun <T> SavedStateHandle.update(key: String, block: (T?) -> T) {
this[key] = block(this[key])
}
fun PwaIcon.resolve(baseUrl: String): String? =
this.src?.let { baseUrl.toHttpUrl().resolve(it) }?.toString()
fun <T> SavedStateHandle.update(key: String, default: T, block: (T) -> T) {
this[key] = block(this[key] ?: default)
}
app/src/main/res/drawable-nodpi/wrapped_bear.png

229 KiB

app/src/main/res/drawable-nodpi/wrapped_cat.png

296 KiB

app/src/main/res/drawable-nodpi/wrapped_clock.png

419 KiB

app/src/main/res/drawable-nodpi/wrapped_coffee_beans.png

203 KiB

app/src/main/res/drawable-nodpi/wrapped_gorilla.png

400 KiB

app/src/main/res/drawable-nodpi/wrapped_jaguar.png

136 KiB

app/src/main/res/drawable-nodpi/wrapped_koala.png

199 KiB

app/src/main/res/drawable-nodpi/wrapped_lion.png

196 KiB

app/src/main/res/drawable-nodpi/wrapped_lynx.png

212 KiB

app/src/main/res/drawable-nodpi/wrapped_moose.png

196 KiB

app/src/main/res/drawable-nodpi/wrapped_rat.png

461 KiB

app/src/main/res/drawable-nodpi/wrapped_reindeer.png

245 KiB

app/src/main/res/drawable-nodpi/wrapped_squirrel.png

405 KiB

[versions]
androidGradlePlugin = "8.1.2"
androidGradlePlugin = "8.1.3"
androidx-activity = "1.8.0"
androidx-appcompat = "1.6.1"
androidx-compose-bom = "2023.10.01"
androidx-compose-compiler = "1.5.3"
androidx-compose-compiler = "1.5.4"
androidx-compose-material = "1.5.0-alpha04"
androidx-compose-material3 = "1.2.0-alpha10"
androidx-compose-runtimetracing = "1.0.0-alpha04"
androidx-compose-tooling = "1.6.0-alpha08"
androidx-datastore = "1.0.0"
androidx-hilt = "1.0.0"
androidx-hilt = "1.1.0"
androidx-navigation = "2.7.5"
androidx-room = "2.6.0"
coil = "2.4.0"
dagger-hilt = "2.48.1"
desugar-jdk = "2.0.4"
kotlin = "1.9.10"
kotlin-ksp = "1.9.10-1.0.13"
kotlin = "1.9.20"
kotlin-ksp = "1.9.20-1.0.14"
kotlinxCoroutines = "1.7.1"
kotlinxDatetime = "0.4.0"
kotlinxSerializationJson = "1.5.1"
......
......@@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "957bb839c1c422a256c594595437ee45",
"identityHash": "e26316f758271c58bc953e756fc16e7d",
"entities": [
{
"tableName": "Drink",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `drinkId` INTEGER NOT NULL, `active` INTEGER NOT NULL, `name` TEXT NOT NULL, `volume` REAL NOT NULL, `caffeine` INTEGER, `price` REAL NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `logoUrl` TEXT NOT NULL, `logoFileName` TEXT NOT NULL, `logoContentType` TEXT NOT NULL, `logoFileSize` INTEGER NOT NULL, `logoUpdatedAt` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `drinkId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `drinkId` INTEGER NOT NULL, `active` INTEGER NOT NULL, `name` TEXT NOT NULL, `volume` TEXT NOT NULL, `caffeine` INTEGER, `price` TEXT NOT NULL, `logoUrl` TEXT, PRIMARY KEY(`serverId`, `drinkId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "serverId",
......@@ -35,7 +35,7 @@
{
"fieldPath": "volume",
"columnName": "volume",
"affinity": "REAL",
"affinity": "TEXT",
"notNull": true
},
{
......@@ -47,50 +47,14 @@
{
"fieldPath": "price",
"columnName": "price",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "createdAt",
"columnName": "createdAt",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updatedAt",
"columnName": "updatedAt",
"affinity": "INTEGER",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "logoUrl",
"columnName": "logoUrl",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "logoFileName",
"columnName": "logoFileName",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "logoContentType",
"columnName": "logoContentType",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "logoFileSize",
"columnName": "logoFileSize",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "logoUpdatedAt",
"columnName": "logoUpdatedAt",
"affinity": "INTEGER",
"notNull": true
"notNull": false
}
],
"primaryKey": {
......@@ -104,7 +68,7 @@
"foreignKeys": [
{
"table": "Server",
"onDelete": "CASCADE",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId"
......@@ -155,7 +119,7 @@
},
{
"tableName": "User",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `userId` INTEGER NOT NULL, `active` INTEGER NOT NULL, `name` TEXT NOT NULL, `email` TEXT NOT NULL, `balance` REAL NOT NULL, `audit` INTEGER NOT NULL, `redirect` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `userId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `userId` INTEGER NOT NULL, `active` INTEGER NOT NULL, `name` TEXT NOT NULL, `email` TEXT, `balance` TEXT NOT NULL, `audit` INTEGER NOT NULL, `redirect` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `userId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "serverId",
......@@ -185,12 +149,12 @@
"fieldPath": "email",
"columnName": "email",
"affinity": "TEXT",
"notNull": true
"notNull": false
},
{
"fieldPath": "balance",
"columnName": "balance",
"affinity": "REAL",
"affinity": "TEXT",
"notNull": true
},
{
......@@ -204,16 +168,43 @@
"columnName": "redirect",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"serverId",
"userId"
]
},
"indices": [],
"foreignKeys": [
{
"table": "Server",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId"
],
"referencedColumns": [
"serverId"
]
}
]
},
{
"fieldPath": "createdAt",
"columnName": "createdAt",
"tableName": "PinnedUser",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `userId` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `userId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`serverId`, `userId`) REFERENCES `User`(`serverId`, `userId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "serverId",
"columnName": "serverId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updatedAt",
"columnName": "updatedAt",
"fieldPath": "userId",
"columnName": "userId",
"affinity": "INTEGER",
"notNull": true
}
......@@ -229,7 +220,7 @@
"foreignKeys": [
{
"table": "Server",
"onDelete": "CASCADE",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId"
......@@ -237,12 +228,25 @@
"referencedColumns": [
"serverId"
]
},
{
"table": "User",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId",
"userId"
],
"referencedColumns": [
"serverId",
"userId"
]
}
]
},
{
"tableName": "Purchase",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `purchaseId` INTEGER NOT NULL, `userId` INTEGER NOT NULL, `drinkId` INTEGER, `difference` REAL NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `purchaseId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`serverId`, `userId`) REFERENCES `User`(`serverId`, `userId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`serverId`, `drinkId`) REFERENCES `Drink`(`serverId`, `drinkId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"tableName": "Transaction",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `transactionId` INTEGER NOT NULL, `userId` INTEGER NOT NULL, `drinkId` INTEGER, `difference` TEXT NOT NULL, `timestamp` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `transactionId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`serverId`, `userId`) REFERENCES `User`(`serverId`, `userId`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`serverId`, `drinkId`) REFERENCES `Drink`(`serverId`, `drinkId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "serverId",
......@@ -251,8 +255,8 @@
"notNull": true
},
{
"fieldPath": "purchaseId",
"columnName": "purchaseId",
"fieldPath": "transactionId",
"columnName": "transactionId",
"affinity": "INTEGER",
"notNull": true
},
......@@ -271,12 +275,12 @@
{
"fieldPath": "difference",
"columnName": "difference",
"affinity": "REAL",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "createdAt",
"columnName": "createdAt",
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
}
......@@ -285,35 +289,35 @@
"autoGenerate": false,
"columnNames": [
"serverId",
"purchaseId"
"transactionId"
]
},
"indices": [
{
"name": "index_Purchase_serverId_userId",
"name": "index_Transaction_serverId_userId",
"unique": false,
"columnNames": [
"serverId",
"userId"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_Purchase_serverId_userId` ON `${TABLE_NAME}` (`serverId`, `userId`)"
"createSql": "CREATE INDEX IF NOT EXISTS `index_Transaction_serverId_userId` ON `${TABLE_NAME}` (`serverId`, `userId`)"
},
{
"name": "index_Purchase_serverId_drinkId",
"name": "index_Transaction_serverId_drinkId",
"unique": false,
"columnNames": [
"serverId",
"drinkId"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_Purchase_serverId_drinkId` ON `${TABLE_NAME}` (`serverId`, `drinkId`)"
"createSql": "CREATE INDEX IF NOT EXISTS `index_Transaction_serverId_drinkId` ON `${TABLE_NAME}` (`serverId`, `drinkId`)"
}
],
"foreignKeys": [
{
"table": "Server",
"onDelete": "CASCADE",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId"
......@@ -324,7 +328,7 @@
},
{
"table": "User",
"onDelete": "CASCADE",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId",
......@@ -354,7 +358,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '957bb839c1c422a256c594595437ee45')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e26316f758271c58bc953e756fc16e7d')"
]
}
}
\ No newline at end of file
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "f794acceadd9ed28da1b218972b5e530",
"entities": [
{
"tableName": "Drink",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `drinkId` INTEGER NOT NULL, `active` INTEGER NOT NULL, `name` TEXT NOT NULL, `volume` TEXT NOT NULL, `caffeine` INTEGER, `price` TEXT NOT NULL, `logoUrl` TEXT NOT NULL, PRIMARY KEY(`serverId`, `drinkId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "serverId",
"columnName": "serverId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "drinkId",
"columnName": "drinkId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "active",
"columnName": "active",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "volume",
"columnName": "volume",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "caffeine",
"columnName": "caffeine",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "price",
"columnName": "price",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "logoUrl",
"columnName": "logoUrl",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"serverId",
"drinkId"
]
},
"indices": [],
"foreignKeys": [
{
"table": "Server",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId"
],
"referencedColumns": [
"serverId"
]
}
]
},
{
"tableName": "Server",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `name` TEXT, `url` TEXT NOT NULL, `logoUrl` TEXT, PRIMARY KEY(`serverId`))",
"fields": [
{
"fieldPath": "serverId",
"columnName": "serverId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "url",
"columnName": "url",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "logoUrl",
"columnName": "logoUrl",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"serverId"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "User",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `userId` INTEGER NOT NULL, `active` INTEGER NOT NULL, `name` TEXT NOT NULL, `email` TEXT NOT NULL, `balance` TEXT NOT NULL, `audit` INTEGER NOT NULL, `redirect` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `userId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "serverId",
"columnName": "serverId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "userId",
"columnName": "userId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "active",
"columnName": "active",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "email",
"columnName": "email",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "balance",
"columnName": "balance",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "audit",
"columnName": "audit",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "redirect",
"columnName": "redirect",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"serverId",
"userId"
]
},
"indices": [],
"foreignKeys": [
{
"table": "Server",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId"
],
"referencedColumns": [
"serverId"
]
}
]
},
{
"tableName": "PinnedUser",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `userId` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `userId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`serverId`, `userId`) REFERENCES `User`(`serverId`, `userId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "serverId",
"columnName": "serverId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "userId",
"columnName": "userId",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"serverId",
"userId"
]
},
"indices": [],
"foreignKeys": [
{
"table": "Server",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId"
],
"referencedColumns": [
"serverId"
]
},
{
"table": "User",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId",
"userId"
],
"referencedColumns": [
"serverId",
"userId"
]
}
]
},
{
"tableName": "Transaction",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`serverId` INTEGER NOT NULL, `transactionId` INTEGER NOT NULL, `userId` INTEGER NOT NULL, `drinkId` INTEGER, `difference` TEXT NOT NULL, `timestamp` INTEGER NOT NULL, PRIMARY KEY(`serverId`, `transactionId`), FOREIGN KEY(`serverId`) REFERENCES `Server`(`serverId`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`serverId`, `userId`) REFERENCES `User`(`serverId`, `userId`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`serverId`, `drinkId`) REFERENCES `Drink`(`serverId`, `drinkId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "serverId",
"columnName": "serverId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "transactionId",
"columnName": "transactionId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "userId",
"columnName": "userId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "drinkId",
"columnName": "drinkId",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "difference",
"columnName": "difference",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"serverId",
"transactionId"
]
},
"indices": [
{
"name": "index_Transaction_serverId_userId",
"unique": false,
"columnNames": [
"serverId",
"userId"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_Transaction_serverId_userId` ON `${TABLE_NAME}` (`serverId`, `userId`)"
},
{
"name": "index_Transaction_serverId_drinkId",
"unique": false,
"columnNames": [
"serverId",
"drinkId"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_Transaction_serverId_drinkId` ON `${TABLE_NAME}` (`serverId`, `drinkId`)"
}
],
"foreignKeys": [
{
"table": "Server",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId"
],
"referencedColumns": [
"serverId"
]
},
{
"table": "User",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId",
"userId"
],
"referencedColumns": [
"serverId",
"userId"
]
},
{
"table": "Drink",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"serverId",
"drinkId"
],
"referencedColumns": [
"serverId",
"drinkId"
]
}
]
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f794acceadd9ed28da1b218972b5e530')"
]
}
}
\ No newline at end of file