Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
313b6e9
Set up SQLDelight
antweb May 3, 2024
e07aeb7
Set up SQLDelight database and initial queries
antweb May 3, 2024
179fdd8
Remove nullability from downloadFile response
antweb May 3, 2024
1f3e56f
Create base classes for SQLDelight sync adapters
antweb May 3, 2024
447c1da
Convert Item sync adapter
antweb May 3, 2024
8e9c599
Convert Cashier sync adapter
antweb May 3, 2024
164eb56
Create extensions with JSON utilities
antweb May 3, 2024
1512f91
Simplify ReceiptLine.toJSON()
antweb May 6, 2024
74ff8dd
Create Item extensions
antweb May 7, 2024
1f8eb80
Add additional tables
antweb May 8, 2024
4508ffe
Move Settings.fiscalJSON extension to core-pos-sdk
antweb May 16, 2024
694bd3d
Enable SQLDelight database on Android
antweb May 16, 2024
d39dfc3
Add additional generic queries
antweb May 17, 2024
776e2c2
Create date adapter for Postgres
antweb May 17, 2024
f8b21ae
Update to latest schema
antweb May 29, 2024
fece4c4
Change to BigDecimal.valueOf() in BigDecimalAdapter
antweb Jun 10, 2024
9577395
Add ItemAddOn.toJSON() method
antweb Jun 10, 2024
b8fa45f
Update Closing column type mapping
antweb Jun 10, 2024
52c2b93
Add additional tables
antweb Jun 10, 2024
73ddfac
Update tests
antweb Jun 10, 2024
ca669e6
Add consistent handling of dates stored as text
antweb Jun 13, 2024
67b7f49
Convert Order sync adapter
antweb Jun 17, 2024
cce399b
Fix Postgres/SQLite incompatibilities
antweb Jun 20, 2024
2403198
Set database version for Postgres builds
antweb Jun 22, 2024
b75ab4d
Define foreign keys as column constraints instead of table constraints
antweb Jun 22, 2024
af93dc9
Add missing foreign keys
antweb Jun 22, 2024
6c51ea2
Move BaseDatabaseTest out of testFixtures
antweb Jun 24, 2024
a1cffcf
Add remaining table definitions
antweb Jun 25, 2024
6a9ce42
Add query to truncate all tables
antweb Jun 26, 2024
4bbd1e1
Update to latest schema
antweb Jun 27, 2024
da2ac59
Add remaining CachedPdfImage queries
robbi5 Jul 15, 2024
127d0f7
Convert BadgeLayout and TicketLayout
robbi5 Jul 15, 2024
7c027ec
Add OrderPosition.selectByServerId query
antweb Jul 23, 2024
c8202ae
Tweak query parameter naming
antweb Jul 23, 2024
589ae21
Remove unused quota query
antweb Jul 23, 2024
ff21ef5
Run tests with Java 17
antweb Jul 23, 2024
2814aa1
Move protobuf plugin version to settings.gradle
antweb Jul 24, 2024
c4263d7
Fix CachedPdfImage query under Postgres
antweb Jul 24, 2024
2bd0a93
Migrate ItemCategorySyncAdapter
antweb Jul 24, 2024
9469978
Migrate SettingsSyncAdapter / InvoiceSettingsSyncAdapter
antweb Jul 24, 2024
d80967d
Migrate EventSyncAdapter
antweb Jul 25, 2024
3f73dee
Migrate SubEventSyncAdapter
antweb Jul 25, 2024
bb52f11
Use ID instead of server ID for updateFromJson queries
antweb Jul 25, 2024
48d5fe5
Add back event slug filter to migrated runBatch queries
antweb Jul 25, 2024
52a0987
Migrate TaxRuleSyncAdapter
antweb Jul 25, 2024
d2439ca
Re-arrange SqBaseConditionalSyncAdapter method order
antweb Jul 25, 2024
9b8483f
Migrate QuestionSyncAdapter
antweb Jul 25, 2024
f1b4337
Migrate CheckInListSyncAdapter
antweb Jul 25, 2024
5935c1f
Migrate AllEventsSyncAdapter
antweb Jul 25, 2024
c652091
Migrate AllSubEventsSyncAdapter
antweb Jul 26, 2024
b80b65d
Migrate BadgeLayoutSyncAdapter
antweb Jul 26, 2024
364e89e
Migrate BadgeLayoutItemSyncAdapter
antweb Jul 26, 2024
fec4f8f
Migrate MediumKeySetSyncAdapter
antweb Jul 26, 2024
05d9634
Use consistent column naming on CheckInList
antweb Jul 26, 2024
075aad7
Migrate BlockedTicketSecretSyncAdapter
antweb Jul 26, 2024
b269612
Add not-null assertion to columns with inconsistent nullability
antweb Jul 26, 2024
9a46a00
Migrate RevokedTicketSecretSyncAdapter
antweb Jul 26, 2024
7647c5e
Migrate ReusableMediaSyncAdapter
antweb Jul 26, 2024
bc3ee78
Migrate TicketLayoutSyncAdapter
antweb Jul 27, 2024
6cc9eb9
Migrate QuotaSyncAdapter
antweb Jul 27, 2024
7d47b21
Clean up old base classes
antweb Jul 27, 2024
9194aeb
Finalize sync adapter migration
antweb Jul 27, 2024
8e35928
Convert Quota.available to Boolean on Postgres
antweb Jul 31, 2024
39ed070
Use IllegalArgumentException for PostgresIdAdapter
antweb Jul 31, 2024
cf43e83
Fix build warnings
antweb Jul 31, 2024
5b05c6f
Tidy up queryKnownIDs
antweb Jul 31, 2024
2aea171
Validate scale in BigDecimalAdapter
antweb Aug 9, 2024
dd4b7cd
Move toScaledBigDecimal/toScaledBigDecimalOrZero to BigDecimalAdapter
antweb Aug 9, 2024
3bbb65c
Move models to libpretixsync
antweb Aug 9, 2024
af9d223
Add receipt ID to ReceiptLine modelAdd receipt ID to ReceiptLine model
antweb Aug 30, 2024
0dfe74f
Enable autoPersist for BlockedTicketSecretSyncAdapter
antweb Sep 20, 2024
5c56232
Remove autoPersist()
antweb Sep 20, 2024
9c3a4b7
Remove database version from Gradle files
antweb Sep 20, 2024
bbad253
Migrate Question usage
antweb Sep 7, 2024
9c45683
Migrate remaining usage of BlockedTicketSecret and RevokedTicketSecret
antweb Sep 7, 2024
dbeda75
Migrate remaining usage of SubEvent
antweb Sep 20, 2024
21dc37f
Migrate remaining usage of Event
antweb Sep 20, 2024
a2d1046
Remove unused deleted counter
antweb Sep 20, 2024
56cb6a9
Create CheckIn model
antweb Sep 20, 2024
ec40955
Migrate remaining usage of CheckIn
antweb Sep 20, 2024
440f540
Fix event slug in AllSubEventsSyncAdapter
antweb Sep 27, 2024
74ccea6
Fix question dependencies
antweb Sep 27, 2024
c5c46df
Fix java.time to Joda conversion
antweb Sep 27, 2024
a2fb476
Migrate remaining usage of CheckInList
antweb Sep 27, 2024
ecdf539
Migrate remaining usage of Item and ItemCategory
antweb Sep 27, 2024
2da10fc
Expand wildcard imports in AsyncCheckProviderTest
antweb Sep 27, 2024
220bba5
Migrate remaining usage of ReusableMedium
antweb Oct 3, 2024
62ef8e7
Migrate majority of OrderPosition in AsyncCheckProvider
antweb Oct 3, 2024
71bb474
Migrate search query in AsyncCheckProvider
antweb Oct 4, 2024
fe7b67a
Expand wildcard import in OrderSyncTest
antweb Oct 4, 2024
0e0f548
Migrate remaining usage of ResourceSyncStatus
antweb Oct 4, 2024
fd8d4a3
Fix typing issue between SQLite and Postgres
antweb Oct 4, 2024
92272a8
Fix now datetime override in tests
antweb Oct 18, 2024
450d7c1
Migrate AsyncCheckProvider.status()
antweb Oct 18, 2024
207aac6
Add missing listed_price to item variation
robbi5 Oct 23, 2024
c45821a
Migrate OrderCleanup
antweb Oct 26, 2024
566ff12
Migrate remaining usage of Order / OrderPosition
antweb Oct 26, 2024
90f197e
Migrate remaining usage of QueuedCall
antweb Oct 26, 2024
5325d45
Migrate remaining usage of QueuedCheckIn
antweb Oct 27, 2024
c469ea8
Remove dataStore arg from check providers
antweb Oct 27, 2024
c6cfd7a
Add query to select BadgeLayoutItem by event slug
antweb Oct 27, 2024
3a3c388
Migrate remaining usage of Closing
antweb Oct 27, 2024
ce2a516
Migrate remaining usage of QueuedOrder
antweb Oct 27, 2024
74ee622
Use 0/1 for booleans in the queries, the shipped sqlite version on an…
robbi5 Nov 13, 2024
52ef4a9
Remove shared SimpleDateFormat instances in date adapters
antweb Nov 15, 2024
1b4d107
Use DateTimeFormatter in date adapters
antweb Nov 15, 2024
4867f11
Add issue_giftcard to test Items
antweb Nov 22, 2024
761752f
Fix boolean handling under Postgres
antweb Nov 22, 2024
4df312d
Remove id parameter from QueuedOrder INSERT
antweb Nov 22, 2024
98e2921
Move query to lock QueuedOrder to compat queries
antweb Nov 22, 2024
07c8b6d
Add default values for Question model properties
antweb Dec 6, 2024
66c3cf7
Migrate Question validation tests
antweb Dec 6, 2024
f79144f
Fix handling of initial receipt
raphaelm Dec 9, 2024
38ec6f5
Migrate SyncManager.uploadReceipts()
antweb Dec 13, 2024
e9fbe55
Move manual migration from SyncManager to android_manual_migrations
antweb Dec 13, 2024
a81d57a
Tax codes (#50)
raphaelm Dec 13, 2024
153c764
Remove remaining requery references from SyncManager
antweb Dec 13, 2024
fc9c742
Fix JSONObject creation
antweb Dec 13, 2024
605d44a
Fix migration race condition by providing sqldelight migration
raphaelm Dec 13, 2024
8095030
Move MediaPolicy out of AbstractItem
antweb Dec 13, 2024
81adaf7
Move AbstractQueuedCheckIn.formatDatetime to new model
antweb Dec 13, 2024
f73dca5
Revert 4937a4a
raphaelm Dec 16, 2024
64b1652
Resolve TODO around addons
raphaelm Dec 17, 2024
919de53
Fix nullability of tax_code
raphaelm Dec 18, 2024
f92d5b7
Add migration to resolve bug remains
raphaelm Dec 18, 2024
e545c67
Replace ItemVariation.listed_price with ItemVariation.display_price
raphaelm Dec 23, 2024
6bb4801
Remove setter from TicketCheckProvider.QuestionAnswer.question
antweb Jan 10, 2025
0decae0
Rename datetime to dateTime
antweb Jan 17, 2025
eb42332
Rename Item.checkInAttention to requiresCheckInAttention
antweb Jan 17, 2025
36ce3bc
Move BadgeLayoutExtensions and TicketLayoutExtensions
antweb Jan 17, 2025
3eb4dc7
Add query to select Questions by server ID list
antweb Jan 22, 2025
9b9e1d9
Remove unused store parameter from EventManager
antweb Feb 5, 2025
48ffb99
Remove remaining references to BlockingEntityStore / Persistable
antweb Feb 12, 2025
f7e35d9
Fix de-serialization of TicketCheckProvider.QuestionAnswer
antweb Feb 19, 2025
1df05a6
Add columns for storing customer invoice details for a upcoming order
robbi5 Jan 27, 2025
cc33827
Better names for email and phone columns
robbi5 Jan 27, 2025
bd9c3a4
Add new properties to toJSON, toModel, requery and fix sqlite syntax
robbi5 Jan 28, 2025
8ce2c1e
Clear local order answer data on receipt after receipt data got uploaded
robbi5 Feb 5, 2025
031e3f5
New types of cash movements
raphaelm Feb 10, 2025
4d981ce
Move pretixSCAN Proxy API types to libpretixsync
antweb Mar 5, 2025
44a470b
Add _version queries
antweb Mar 12, 2025
f520eb6
Add SQLDelight migrations
antweb Mar 12, 2025
4249414
Move common migrations to common dir
antweb Mar 26, 2025
fcaac06
Add SQLDelight migration utilities
antweb Apr 2, 2025
172d0bf
Add SQLDelight migrations for schema versions 77 to 91
antweb Apr 2, 2025
d09dd4c
Update migrations after validation
antweb Apr 9, 2025
0ec2cd9
Document migration validation
antweb Apr 9, 2025
2f03711
Fix migration from schema version 79 to 80
antweb Apr 16, 2025
aee2979
Use screaming snake case for constants
antweb Apr 16, 2025
96e9ab7
Add constant for the default database name
antweb Apr 16, 2025
f4285a5
Remove outdated requery references
antweb Apr 16, 2025
05c0763
Migrate BaseDatabaseTest
antweb Apr 16, 2025
331f908
Move CURRENT_VERSION constant to new Migrations class
antweb Apr 16, 2025
2992a42
Use SyncDatabase.Schema.version to get current schema version
antweb Apr 17, 2025
16d46c0
Add serverId to SubEvent model
antweb May 8, 2025
aea6019
Add additional Order / OrderPosition model properties
antweb May 21, 2025
e9c9c69
Use previous parsing logic for OrderPosition.variationServerId
antweb May 21, 2025
a1b93dc
Avoid var variable name
antweb May 21, 2025
4a5f21c
Add index on receipt for server_id
robbi5 May 15, 2025
96b4b1e
Create MediumKeySet model
antweb May 21, 2025
a61c7eb
Add selectAll query for MediumKeySet
antweb May 21, 2025
ec98ed4
Add isInTestMode to Event model
antweb May 28, 2025
b33e714
Add additional common queries
antweb May 28, 2025
2c5d559
Add payments and refunds properties to Order model
antweb May 28, 2025
c63d30c
Add BlockedTicketSecret table to migration 91
robbi5 Jul 7, 2025
834a363
Flip 80 and 81 migrations
robbi5 Jul 15, 2025
1033e70
Move BlockedTicketSecret migration into 90 (so it is available in db …
robbi5 Jul 15, 2025
7321934
Skip SQLDelight schema validation
antweb Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ on:

jobs:
test:
strategy:
matrix:
java: [ '11' ]

name: test with java ${{ matrix.java }}

name: test
runs-on: ubuntu-latest

steps:
Expand All @@ -22,13 +17,13 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
java-version: '17'
distribution: 'temurin'

- name: Run Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: clean check test build jar jacocoTestReport
arguments: clean check test build jar jacocoTestReport -x verifyMainSyncDatabaseMigration
build-root-directory: libpretixsync

- name: Codecov
Expand Down
15 changes: 14 additions & 1 deletion libpretixsync/build-postgres.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ plugins {
id 'jacoco'
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.kotlin.kapt'
id 'com.google.protobuf' version '0.9.4'
id 'com.google.protobuf'
id 'com.github.gmazzo.buildconfig' version "5.3.5"
id 'org.gradle.idea'
id 'app.cash.sqldelight'
}
apply from: 'versions.gradle'

Expand Down Expand Up @@ -107,6 +108,8 @@ dependencies {
implementation "net.i2p.crypto:eddsa:$eddsa_version"
implementation "com.google.protobuf:protobuf-javalite:$protobuf_version"

implementation "app.cash.sqldelight:jdbc-driver:$sqldelight_version"

kapt "io.requery:requery-processor:$requery_version"
annotationProcessor "javax.annotation:jsr250-api:$jsr250_version"

Expand All @@ -121,3 +124,13 @@ task copyTestResources(type: Copy) {
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources

sqldelight {
databases {
SyncDatabase {
packageName = "eu.pretix.libpretixsync.sqldelight"
dialect "app.cash.sqldelight:postgresql-dialect:$sqldelight_version"
srcDirs('src/main/sqldelight/postgres', 'src/main/sqldelight/common', 'src/main/sqldelight/migrations')
}
}
}
32 changes: 31 additions & 1 deletion libpretixsync/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ plugins {
id 'jacoco'
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.kotlin.kapt'
id 'com.google.protobuf' version '0.9.4'
id 'com.google.protobuf'
id 'com.github.gmazzo.buildconfig' version '5.3.5'
id 'org.gradle.idea'
id 'app.cash.sqldelight'
}
apply from: 'versions.gradle'

Expand Down Expand Up @@ -104,6 +105,8 @@ dependencies {
implementation "net.i2p.crypto:eddsa:$eddsa_version"
implementation "com.google.protobuf:protobuf-javalite:$protobuf_version"

implementation "app.cash.sqldelight:sqlite-driver:$sqldelight_version"

kapt "io.requery:requery-processor:$requery_version"
annotationProcessor "javax.annotation:jsr250-api:$jsr250_version"

Expand All @@ -118,3 +121,30 @@ task copyTestResources(type: Copy) {
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources

sqldelight {
databases {
SyncDatabase {
packageName = "eu.pretix.libpretixsync.sqldelight"
srcDirs('src/main/sqldelight/sqlite', 'src/main/sqldelight/common', 'src/main/sqldelight/migrations')

// SQLDelight supports migration validation by running the migrations against a database file from a
// previous version and comparing the result against the current schema.
//
// The database dumps can be generated with the Gradle task `generateMainSyncDatabaseSchema`, which will
// place a .db file in `schemaOutputDirectory` (e.g. 100.db for schema version 100).
//
// Unfortunately, the validation is buggy for complex schemas (see https://github.com/sqldelight/sqldelight/issues/4759)
// and will hang or run out of memory in the current release.
//
// Running the `verifyMainSyncDatabaseMigration` is still helpful to check the syntax of the migrations.
schemaOutputDirectory.set(file("src/main/sqldelight/sqlite"))


// Oldest dialect supported by SQLDelight 2.0.2
// In Android projects, it will auto-select based on SDK
// but not go lower than 3.18 (Android 9 is still on 3.8)
dialect "app.cash.sqldelight:sqlite-3-18-dialect:$sqldelight_version"
}
}
}
3 changes: 2 additions & 1 deletion libpretixsync/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pluginManagement {
// but building it inside the multi module project doesn't exit with "unknown version already on classpath" error
plugins {
id "org.jetbrains.kotlin.jvm" version "1.9.23" apply false
id "com.google.protobuf" version "0.9.4" apply false
id "app.cash.sqldelight" version "2.0.2" apply false
}

rootProject.name = 'eu.pretix.libpretixsync'

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import eu.pretix.libpretixsync.DummySentryImplementation
import eu.pretix.libpretixsync.SentryInterface
import eu.pretix.libpretixsync.config.ConfigStore
import eu.pretix.libpretixsync.db.Answer
import eu.pretix.libpretixsync.db.Question
import eu.pretix.libpretixsync.db.QueuedCheckIn
import eu.pretix.libpretixsync.models.Question
import eu.pretix.libpretixsync.models.QueuedCheckIn
import eu.pretix.libpretixsync.utils.NetUtils
import eu.pretix.libpretixsync.utils.URLFragmentEncoder
import okhttp3.MediaType
Expand Down Expand Up @@ -73,9 +73,9 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
"pdf" -> "application/pdf".toMediaTypeOrNull()!!
else -> "application/unknown".toMediaTypeOrNull()!!
}, a.value.split("/").last())
answerbody.put("" + (a.question as Question).getServer_id(), fileid)
answerbody.put("" + (a.question as Question).serverId, fileid)
} else {
answerbody.put("" + (a.question as Question).getServer_id(), a.value)
answerbody.put("" + (a.question as Question).serverId, a.value)
}
}
}
Expand Down Expand Up @@ -120,9 +120,9 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
"pdf" -> "application/pdf".toMediaTypeOrNull()!!
else -> "application/unknown".toMediaTypeOrNull()!!
}, a.value.split("/").last())
answerbody.put("" + (a.question as Question).getServer_id(), fileid)
answerbody.put("" + (a.question as Question).serverId, fileid)
} else {
answerbody.put("" + (a.question as Question).getServer_id(), a.value)
answerbody.put("" + (a.question as Question).serverId, a.value)
}
}
}
Expand Down Expand Up @@ -314,7 +314,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
}

@Throws(ApiException::class)
open fun downloadFile(full_url: String): ApiResponse? {
open fun downloadFile(full_url: String): ApiResponse {
var request = Request.Builder()
.url(full_url)
.header("Authorization", "Device $key")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package eu.pretix.libpretixsync.api

import eu.pretix.libpretixsync.db.Answer
import eu.pretix.libpretixsync.db.QuestionOption
import eu.pretix.libpretixsync.models.db.toModel
import eu.pretix.libpretixsync.sqldelight.SyncDatabase

/**
* API types for the pretixSCAN Proxy
*
* Used as common types between the ProxyCheckProvider and the Proxy API endpoints.
*
* They replicate the field names of the old requery models, which were sent in the requests before the SQLDelight
* migration. This should provide reasonable backwards compatibility.
*/

data class MultiCheckInput(
val events_and_checkin_lists: Map<String, Long>,
val ticketid: String,
val answers: List<CheckInputAnswer>?,
val ignore_unpaid: Boolean,
val with_badge_data: Boolean,
val type: String?,
val source_type: String?,

// TODO: Check unused values
val allowQuestions: Boolean,
val nonce: String?
)

data class CheckInput(
val ticketid: String,
val answers: List<CheckInputAnswer>?,
val ignore_unpaid: Boolean,
val with_badge_data: Boolean,
val type: String?,
val source_type: String?
)

data class CheckInputAnswer(
var question: CheckInputQuestion,
var value: String,
var options: List<QuestionOption>? = null
) {
fun toAnswer(db: SyncDatabase): Answer {
val q = db.questionQueries.selectByServerId(question.server_id).executeAsOne().toModel()
return Answer(q, value, options)
}
}

data class CheckInputQuestion(
val server_id: Long,
)

data class SearchInput(
val query: String,
val page: Int,

// TODO: Check unused values
val events_and_checkin_lists: Map<String, Long>,
)
Loading
Loading