@@ -40,7 +40,6 @@ class OrderSyncAdapter(
4040) : BaseDownloadSyncAdapter<Order, String>(db, api, syncCylceId, eventSlug, fileStorage, feedback) {
4141
4242 private val itemCache: MutableMap <Long , Item > = HashMap ()
43- private val listCache: MutableMap <Long , CheckInList > = HashMap ()
4443 private val checkinCache: MutableMap <Long , MutableList <CheckIn >> = HashMap ()
4544 private val checkinCreateCache: MutableList <CheckIn > = ArrayList ()
4645
@@ -112,7 +111,7 @@ class OrderSyncAdapter(
112111 }
113112 }
114113
115- private fun preparePositionObject (obj : OrderPosition ? , jsonobj : JSONObject , orderId : Long , jsonorder : JSONObject , parent : JSONObject ? ): OrderPosition {
114+ private fun preparePositionObject (jsonobj : JSONObject , orderId : Long , jsonorder : JSONObject , parent : JSONObject ? ): OrderPosition {
116115 val jsonName = if (jsonobj.isNull(" attendee_name" )) " " else jsonobj.optString(" attendee_name" )
117116 // TODO: BUG: jsonName can never be null, so parent / jInvoiceAddress is never used
118117 // Keeping old behaviour for compatibility
@@ -157,7 +156,7 @@ class OrderSyncAdapter(
157156 }
158157
159158 private fun insertPositionObject (jsonobj : JSONObject , orderId : Long , jsonorder : JSONObject , parent : JSONObject ? ) {
160- val posobj = preparePositionObject(null , jsonobj, orderId, jsonorder, parent)
159+ val posobj = preparePositionObject(jsonobj, orderId, jsonorder, parent)
161160
162161 val id = db.orderPositionQueries.transactionWithResult {
163162 db.orderPositionQueries.insert(
@@ -180,7 +179,7 @@ class OrderSyncAdapter(
180179 }
181180
182181 private fun updatePositionObject (obj : OrderPosition , jsonobj : JSONObject , orderId : Long , jsonorder : JSONObject , parent : JSONObject ? ) {
183- val posobj = preparePositionObject(obj, jsonobj, orderId, jsonorder, parent)
182+ val posobj = preparePositionObject(jsonobj, orderId, jsonorder, parent)
184183
185184 db.orderPositionQueries.updateFromJson(
186185 attendee_email = posobj.attendee_email,
@@ -359,26 +358,26 @@ class OrderSyncAdapter(
359358 override fun deleteUnseen (): Boolean = false
360359
361360 override fun downloadPage (url : String , isFirstPage : Boolean ): JSONObject ? {
362- var url = url
363361 if (isFirstPage) {
364362 rlm = db.resourceSyncStatusQueries.selectByResourceAndEventSlug(
365363 resource = rlmName(),
366364 event_slug = eventSlug,
367365 ).executeAsOneOrNull()
368366 }
369367 var is_continued_fetch = false
370- if (! url.contains(" testmode=" )) {
371- url + = if (url.contains(" ?" )) {
368+ var resUrl = url
369+ if (! resUrl.contains(" testmode=" )) {
370+ resUrl + = if (resUrl.contains(" ?" )) {
372371 " &"
373372 } else {
374373 " ?"
375374 }
376- url + = " testmode=false&exclude=downloads&exclude=payment_date&exclude=payment_provider&exclude=fees&exclude=positions.downloads"
375+ resUrl + = " testmode=false&exclude=downloads&exclude=payment_date&exclude=payment_provider&exclude=fees&exclude=positions.downloads"
377376 if (! isPretixpos) {
378- url + = " &exclude=payments&exclude=refunds"
377+ resUrl + = " &exclude=payments&exclude=refunds"
379378 }
380379 if (withPdfData) {
381- url + = " &pdf_data=true"
380+ resUrl + = " &pdf_data=true"
382381 }
383382 }
384383
@@ -408,8 +407,8 @@ class OrderSyncAdapter(
408407
409408 is_continued_fetch = true
410409 try {
411- if (! url .contains(" created_since" )) {
412- url + = " &ordering=datetime&created_since=" + URLEncoder .encode(resourceSyncStatus.status.substring(11 ), " UTF-8" ) + firstrun_params
410+ if (! resUrl .contains(" created_since" )) {
411+ resUrl + = " &ordering=datetime&created_since=" + URLEncoder .encode(resourceSyncStatus.status.substring(11 ), " UTF-8" ) + firstrun_params
413412 }
414413 } catch (e: UnsupportedEncodingException ) {
415414 e.printStackTrace()
@@ -429,20 +428,20 @@ class OrderSyncAdapter(
429428 // of the first page.
430429
431430 try {
432- if (! url .contains(" modified_since" )) {
433- url + = " &ordering=-last_modified&modified_since=" + URLEncoder .encode(resourceSyncStatus.last_modified, " UTF-8" )
431+ if (! resUrl .contains(" modified_since" )) {
432+ resUrl + = " &ordering=-last_modified&modified_since=" + URLEncoder .encode(resourceSyncStatus.last_modified, " UTF-8" )
434433 }
435434 } catch (e: UnsupportedEncodingException ) {
436435 e.printStackTrace()
437436 }
438437 }
439438 } else {
440- if (! url .contains(" subevent_after" )) {
441- url + = firstrun_params
439+ if (! resUrl .contains(" subevent_after" )) {
440+ resUrl + = firstrun_params
442441 }
443442 }
444443
445- val apiResponse = api.fetchResource(url )
444+ val apiResponse = api.fetchResource(resUrl )
446445 if (isFirstPage && ! is_continued_fetch) {
447446 firstResponseTimestamp = apiResponse.response.header(" X-Page-Generated" )
448447 }
0 commit comments