Skip to content

Commit

Permalink
Remove legacy code for item-badge relationship (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm authored May 15, 2024
1 parent 86144ff commit ae2bd66
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public class AbstractItem implements RemoteObject {
@JsonIgnore
List<Quota> quotas;

@Nullable
public Long badge_layout_id;

@Nullable
public Long ticket_layout_id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public class Migrations {
private static EntityModel model = Models.DEFAULT;
public static int CURRENT_VERSION = 99;
public static int CURRENT_VERSION = 100;

private static void createVersionTable(Connection c, int version) throws SQLException {
Statement s2 = c.createStatement();
Expand Down Expand Up @@ -397,6 +397,10 @@ public static void migrate(DataSource dataSource, boolean dbIsNew) throws SQLExc
execIgnore(c, "ALTER TABLE Item ADD checkin_text TEXT NULL;", new String[] {"duplicate column name", "already exists", "existiert bereits"});
updateVersionTable(c, 99);
}
if (db_version < 100) {
execIgnore(c, "ALTER TABLE Item DROP COLUMN badge_layout_id;", new String[] {"not exists", "existiert"});
updateVersionTable(c, 100);
}

// Note that the Android app currently does not use these queries!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,6 @@ public void updateObject(BadgeLayout obj, JSONObject jsonobj) throws JSONExcepti
obj.setServer_id(jsonobj.getLong("id"));
obj.setJson_data(jsonobj.toString());

/* Legacy mechanism: Keep around until pretix 2.5 is end of life */
JSONArray assignmentarr = jsonobj.getJSONArray("item_assignments");
List<Long> itemids = new ArrayList<>();
for (int i = 0; i < assignmentarr.length(); i++) {
itemids.add(assignmentarr.getJSONObject(i).getLong("item"));
}
List<Item> items_to_remove;
if (!itemids.isEmpty()) {
List<Item> items = store.select(Item.class).where(
Item.SERVER_ID.in(itemids)
).get().toList();
for (Item item : items) {
item.setBadge_layout_id(obj.getServer_id());
store.update(item, Item.BADGE_LAYOUT_ID);
}
items_to_remove = store.select(Item.class).where(
Item.SERVER_ID.notIn(itemids).and(
Item.BADGE_LAYOUT_ID.eq(obj.getServer_id())
)
).get().toList();
} else {
items_to_remove = store.select(Item.class).where(
Item.BADGE_LAYOUT_ID.eq(obj.getServer_id())
).get().toList();
}
for (Item item : items_to_remove) {
item.setBadge_layout_id(null);
store.update(item, Item.BADGE_LAYOUT_ID);
}
/* End of legacy mechanism: Keep around until pretix 2.5 is end of life */

String remote_filename = jsonobj.optString("background");
if (remote_filename != null && remote_filename.startsWith("http")) {
String hash = HashUtils.toSHA1(remote_filename.getBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,7 @@ protected void downloadData(ProgressFeedback feedback, Boolean skip_orders, Stri
download(new TicketLayoutSyncAdapter(dataStore, fileStorage, eventSlug, api, configStore.getSyncCycleId(), feedback));
}
download(new BadgeLayoutSyncAdapter(dataStore, fileStorage, eventSlug, api, configStore.getSyncCycleId(), feedback));
try {
download(new BadgeLayoutItemSyncAdapter(dataStore, fileStorage, eventSlug, api, configStore.getSyncCycleId(), feedback));
} catch (ApiException e) {
// ignore, this is only supported from pretix 2.5. We have legacy code in BadgeLayoutSyncAdapter to fall back to
}
download(new BadgeLayoutItemSyncAdapter(dataStore, fileStorage, eventSlug, api, configStore.getSyncCycleId(), feedback));
download(new CheckInListSyncAdapter(dataStore, fileStorage, eventSlug, api, configStore.getSyncCycleId(), feedback, subEvent));
if (profile == Profile.PRETIXSCAN || profile == Profile.PRETIXSCAN_ONLINE) {
// We don't need these on pretixPOS, so we can save some traffic
Expand Down

0 comments on commit ae2bd66

Please sign in to comment.