-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have one Coupon for each CouponCode #2116
Conversation
@@ -48,7 +48,7 @@ object CouponCodes | |||
requestedLimit >= prefixSize + minSuffixSize | |||
} | |||
|
|||
def generateCodes(prefix: String, codeCharacterLength: Int, quantity: Int, attempt: Int = 0): Seq[String] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙄
mutateOrFailures { | ||
CouponManager.getCodes(id) | ||
} | ||
// TODO: get rid of this route → code is already provided in CouponResponse.Root @michalrus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it won't be used, then yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bagratinho, when tackling this, would you verify that we don’t use
return Api.get(`/coupons/codes/${id}`); |
CouponManager.update(id, payload, context, auth.model) | ||
} | ||
} ~ | ||
// FIXME: unused? @michalrus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bagratinho tells me we’re not updating coupons. 🔥?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's UI for that. @bswineford ?
CouponResponse.build(context, code, coupon, fas.form, fas.shadow) | ||
} | ||
|
||
// TODO: really? Two log events for each coupon code? @michalrus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmmmm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably for coupons and coupon codes separately. I think this can be changed to one activity logging. Same for bulk gen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why does .couponCreated
change scope
and .singleCouponCodeCreated
doesn’t? :<
https://github.com/FoxComm/highlander/pull/2116/files#r121897193
_ ← * <~ CouponCodes.createAll(unsaved) | ||
_ ← * <~ LogActivity().multipleCouponCodeCreated(coupon, Some(admin)) | ||
} yield generated | ||
code <- CouponCodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, cute, git-diff
decided we’re copying code enough so that it can show it like that. 😛
CouponManager.create(payload, context.name, None).map { newCoupon ⇒ | ||
source.copy(formId = newCoupon.id) | ||
CouponManager.create(payload, context.name, None).map { newCoupons ⇒ | ||
newCoupons.map(newCoupon => source.copy(formId = newCoupon.id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, what do these SimpleModels
actually give us, over using just Models
?
Apart from increasing the amount of code to maintain, that is. 😛
generateCodes: Option[GenerateCouponCodes]) | ||
|
||
// FIXME: unused? @michalrus | ||
//case class UpdateCoupon(attributes: Map[String, Json], promotion: Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Seems you can remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s wait for @bswineford / @bagratinho, but I don’t see UI for editing coupons either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or whatever, I’m removing this.
mutateOrFailures { | ||
CouponManager.getCodes(id) | ||
} | ||
// TODO: get rid of this route → code is already provided in CouponResponse.Root @michalrus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it won't be used, then yes
CouponManager.update(id, payload, context, auth.model) | ||
} | ||
} ~ | ||
// FIXME: unused? @michalrus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's UI for that. @bswineford ?
.insert(couponFormAndShadow.form, couponFormAndShadow.shadow, payload.schema)) | ||
|
||
coupons = formsAndShadows.map( | ||
fas => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs reformat?
CouponResponse.build(context, code, coupon, fas.form, fas.shadow) | ||
} | ||
|
||
// TODO: really? Two log events for each coupon code? @michalrus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably for coupons and coupon codes separately. I think this can be changed to one activity logging. Same for bulk gen
def generate(code: String)(implicit aa: TestAdminAuth): HttpResponse = | ||
POST(s"$rootPrefix/coupons/codes/generate/$formId/$code", aa.jwtCookie.some) | ||
} | ||
// TODO: unused @michalrus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
& an appliance for Bagrat ⇒ https://foxcommerce.slack.com/archives/C1DMVNVLM/p1497361174779856 |
} | ||
|
||
_ ← * <~ coupons.headOption.traverse { firstCoupon ⇒ | ||
// TODO: Should they override scope? (`LogActivity().withScope(scope)`) @michalrus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did .couponCreated
change scope
and .singleCouponCodeCreated
didn’t? :<
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe…
@@ -20,7 +20,7 @@ | |||
|
|||
### View Illuminated [GET /v1/promotions/{context}/{id}/baked] | |||
|
|||
Return illuminated version of promotion. | |||
Return illuminated version of promotion. FIXME: This is very behind right now. @michalrus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…?
Current status: blocked by |
#2184 Ashes changes |
Conflict |
When trying to redeploy:
EDIT: twice. I’ll try to disable it. |
https://foxcommerce.slack.com/archives/C04BAMY6Q/p1498004943506145 https://foxcommerce.slack.com/archives/C04BAMY6Q/p1497899410611530 Does new appliance base mean, that I have to destroy & up? :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a couple things that we should change:
-
For item qualifiers, give an option for any product to qualify
-
Change text of "Items for qualify" to "Qualifying items"
-
This UX feels pretty confusing -- what does it mean?
-
We don't seem to be forcing a choice on usage rules. What does this state mean?
-
I set my offer on a promotion to be free shipping, it appears that I'm going to be charged shipping, even though I'm not
-
If an exclusive promotion is on the cart and I try to add a promotion that is not exclusive, it kicks the exclusive promotion off
We don't necessarily need to fix up all of this, but wanted to highlight the issues.
Also, items based promotions don't seem to be working for me. |
@jmataya I would say we better create new issue(s) for points described above in your comments, IMO that should be tackled separately, not in this PR, as this one is related to coupon creation. Not promo. |
Yes, let’s have small diffs, it would be easier! |
@jmataya I created issues for everything you highlighted, except for the last one.
I believe we have decided that user actions of applying coupons are more important than auto-applied promos. Correct me if I'm wrong tho |
Resolves #1489
So what this does is:
CreateCoupon
payload has two more fields:singleCode :: String
, if you want a single codegenerateCodes :: ThatPreviousGenerateCodes
, which is{ prefix :: String, quantity :: Int, length :: Int}
, if you want multiple codes.code :: String
.@bagratinho, I need your help with redoing that part of Ashes that’s sending the coupon creation request and (possibly) parsing its response. 🙏 📿