Skip to content

Commit 1180997

Browse files
committed
Add back event slug filter to migrated runBatch queries
Some of the migrated sync adapters are missing the event slug filter in runBatch that was present in the original version.
1 parent cf21776 commit 1180997

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

libpretixsync/src/main/java/eu/pretix/libpretixsync/sync/ItemCategorySyncAdapter.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,8 @@ class ItemCategorySyncAdapter(
7575
}
7676

7777
override fun runBatch(parameterBatch: List<Long>): List<ItemCategory> =
78-
db.itemCategoryQueries.selectByServerIdList(parameterBatch).executeAsList()
78+
db.itemCategoryQueries.selectByServerIdListAndEventSlug(
79+
server_id = parameterBatch,
80+
event_slug = eventSlug,
81+
).executeAsList()
7982
}

libpretixsync/src/main/java/eu/pretix/libpretixsync/sync/ItemSyncAdapter.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ class ItemSyncAdapter(
150150
}
151151

152152
override fun runBatch(parameterBatch: List<Long>): List<Item> =
153-
db.itemQueries.selectByServerIdList(parameterBatch).executeAsList()
153+
db.itemQueries.selectByServerIdListAndEventSlug(
154+
server_id = parameterBatch,
155+
event_slug = eventSlug,
156+
).executeAsList()
154157

155158
@Throws(JSONException::class)
156159
fun standaloneRefreshFromJSON(data: JSONObject) {

libpretixsync/src/main/java/eu/pretix/libpretixsync/sync/OrderSyncAdapter.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@ class OrderSyncAdapter(
508508
}
509509

510510
override fun runBatch(parameterBatch: List<String>): List<Order> {
511+
// pretix guarantees uniqueness of CODE within an organizer account, so we don't need
512+
// to filter by EVENT_SLUG. This is good, because SQLite tends to build a very stupid
513+
// query plan otherwise if statistics are not up to date (using the EVENT_SLUG index
514+
// instead of using the CODE index)
511515
return db.orderQueries.selectByCodeList(parameterBatch).executeAsList()
512516
}
513517

libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/Item.sq

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ SELECT *
1212
FROM Item
1313
WHERE id = ?;
1414

15-
selectByServerIdList:
15+
selectByServerIdListAndEventSlug:
1616
SELECT *
1717
FROM Item
18-
WHERE server_id IN ?;
18+
WHERE server_id IN ? AND event_slug = ?;
1919

2020
selectServerIdsByEventSlug:
2121
SELECT server_id

libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/ItemCategory.sq

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ SELECT *
88
FROM ItemCategory
99
WHERE server_id = ?;
1010

11-
selectByServerIdList:
11+
selectByServerIdListAndEventSlug:
1212
SELECT *
1313
FROM ItemCategory
14-
WHERE server_id IN ?;
14+
WHERE server_id IN ? AND event_slug = ?;
1515

1616
selectServerIdsByEventSlug:
1717
SELECT server_id

0 commit comments

Comments
 (0)