Manos Chorianopoulos

inactive sm coupon fixes

......@@ -161,17 +161,22 @@ import SwiftEventBus
func matchOldSMCoupons() {
var oldUnifiedCouponsArray:Array<swiftApi.CouponItemModel> = []
for smCouponSet in swiftApi().getCouponSetsDealsList() {
for oldCoupon in swiftApi().getAllOldCouponList() {
if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) {
oldCoupon.setCouponSetData(smCouponSet);
oldUnifiedCouponsArray.append(oldCoupon);
// TODO: Check - Old implementation
// for smCouponSet in swiftApi().getCouponSetsDealsList() {
// for oldCoupon in swiftApi().getAllOldCouponList() {
// if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) {
//
// oldCoupon.setCouponSetData(smCouponSet);
// oldUnifiedCouponsArray.append(oldCoupon);
//
// break;
// }
// }
// }
break;
}
}
}
// TODO: DELETE - TEST
// oldUnifiedCouponsArray = swiftApi().getAllOldCouponList().filter({ return $0.couponset_data?.couponset_type == "supermarket" })
oldUnifiedCouponsArray = swiftApi().getSMOldCouponList()
oldUnifiedCouponsArray.sort(by: {
let date1 = $0.redeemed_date
......
......@@ -715,17 +715,22 @@ import SwiftEventBus
func matchOldSMCoupons() {
var oldUnifiedCouponsArray:Array<swiftApi.CouponItemModel> = []
for smCouponSet in swiftApi().getCouponSetsDealsList() {
for oldCoupon in swiftApi().getAllOldCouponList() {
if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) {
oldCoupon.setCouponSetData(smCouponSet);
oldUnifiedCouponsArray.append(oldCoupon);
// TODO: Check - Old implementation
// for smCouponSet in swiftApi().getCouponSetsDealsList() {
// for oldCoupon in swiftApi().getAllOldCouponList() {
// if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) {
//
// oldCoupon.setCouponSetData(smCouponSet);
// oldUnifiedCouponsArray.append(oldCoupon);
//
// break;
// }
// }
// }
break;
}
}
}
// TODO: DELETE - TEST
// oldUnifiedCouponsArray = swiftApi().getAllOldCouponList().filter({ return $0.couponset_data?.couponset_type == "supermarket" })
oldUnifiedCouponsArray = swiftApi().getSMOldCouponList()
oldUnifiedCouponsArray.sort(by: {
let date1 = $0.redeemed_date
......
......@@ -16,6 +16,7 @@ public struct GlobalVariables {
static var dfyCoupons: Array<swiftApi.ActiveDFYCouponModel> = []
static var couponList: Array<swiftApi.CouponItemModel> = []
static var oldCouponList: Array<swiftApi.CouponItemModel> = []
static var smOldCouponList: Array<swiftApi.CouponItemModel> = []
static var allOldCouponList: Array<swiftApi.CouponItemModel> = []
static var couponSetList: Array<swiftApi.CouponSetItemModel> = []
static var couponsetsDealsList: Array<swiftApi.CouponSetItemModel> = [] // Supermarket couponsets
......@@ -5345,6 +5346,37 @@ public class swiftApi {
return GlobalVariables.oldCouponList
}
public func setSMOldCouponList(_ coupons: Array<CouponItemModel>) {
// let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) }
var oldCoupons = coupons.filter({ return $0.status == 0 }).filter({ return $0.couponset_data?.couponset_type == "supermarket" })
// sort oldCoupons by redeemed date
// let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "dd/MM/yyyy"
oldCoupons.sort(by: {
// let date1 = dateFormatter.date(from: $0.redeemed ?? "")
// let date2 = dateFormatter.date(from: $1.redeemed ?? "")
let date1 = $0.redeemed_date
let date2 = $1.redeemed_date
if ((date1 != nil) && (date2 != nil)) {
return date1!.compare(date2!) == .orderedDescending
} else {
return false
}
})
GlobalVariables.smOldCouponList = oldCoupons
}
public func getSMOldCouponList() -> Array<CouponItemModel> {
return GlobalVariables.smOldCouponList
}
public func setAllOldCouponList(_ coupons: Array<CouponItemModel>) {
// let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) }
var oldCoupons = coupons.filter({ return $0.status == 0 })
......@@ -8422,6 +8454,8 @@ public class swiftApi {
swiftApi().setAllOldCouponList(couponsArray)
// <==
swiftApi().setSMOldCouponList(couponsArray)
let noSMCoupons = couponsArray.filter({ return $0.couponset_data?.couponset_type != "supermarket" })
swiftApi().setCouponList(noSMCoupons)
......