Closed smnirven closed 9 years ago
This is due to a type mismatch between the last-order-max-discount amount we store in the offer_conditions table (integer), and the discount amount stored in the data field of the events table (string representation of a floating point number).
I think we should make 'em floating point on both sides - especially since the dashboard input text box has an example shown as "10.00".
Also, I noticed the offer condition that uses last-order-value is going to have the same problem because last-order-value in the offer_conditions table is also an integer
Seeing these errors in staging when browsing the store with a site_shopper_id that has recently placed orders with a discount. Seems like we should not be casting the discount amount to an integer here: https://github.com/promotably/api/blob/master/src/api/models/event.clj#L111
java.lang.NumberFormatException: For input string: "1.5" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:492) at java.math.BigInteger.(BigInteger.java:338)
at java.math.BigInteger.(BigInteger.java:476)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at clojure.lang.Reflector.invokeConstructor(Reflector.java:180)
at clojure.core$bigint.invoke(core.clj:3349)
at api.models.event$fn18580$discount_last_order18581$fn18582.invoke(event.clj:111)
at api.models.event$fn18580$discount_last_order18581.invoke(event.clj:106)
at api.models.offer_condition$fn19586.invoke(offer_condition.clj:203)
at clojure.lang.MultiFn.invoke(MultiFn.java:231)
at api.models.offer$valid_QMARKSTAR_$fn20376.invoke(offer.clj:281)
at clojure.core$map$fn4245.invoke(core.clj:2557)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:484)
at clojure.core$seq.invoke(core.clj:133)
at clojure.core$everyQMARK.invoke(core.clj:2494)
at api.models.offer$valid_QMARK_STAR.invoke(offer.clj:295)
at api.models.offer$validQMARK.invoke(offer.clj:303)
at api.controllers.offers$find_valid_offers$fn22277.invoke(offers.clj:164)
at clojure.core$filter$fn4264.invoke(core.clj:2605)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:484)
at clojure.core$seq.invoke(core.clj:133)
at api.controllers.offers$select_offer.invoke(offers.clj:144)
at api.controllers.offers$get_available_offers.invoke(offers.clj:201)
at api.route$fn26740$fn26747$fn26748.invoke(route.clj:94)
at compojure.response$fn25733.invoke(response.clj:32)
at compojure.response$fn25710$G25705__25717.invoke(response.clj:9)
at compojure.core$make_route$fn25829.invoke(core.clj:100)
at compojure.core$if_route$fn25817.invoke(core.clj:46)
at compojure.core$if_method$fn25810.invoke(core.clj:31)
at compojure.core$routing$fn25835.invoke(core.clj:113)
at clojure.core$some.invoke(core.clj:2515)
at compojure.core$routing.doInvoke(core.clj:113)
at clojure.lang.RestFn.invoke(RestFn.java:628)
at api.route$fn__26740.invoke(route.clj:99)
at compojure.core$wrap_context$fn25854.invoke(core.clj:177)
at compojure.core$if_route$fn25817.invoke(core.clj:46)
at compojure.core$routing$fn25835.invoke(core.clj:113)
at clojure.core$some.invoke(core.clj:2515)
at compojure.core$routing.doInvoke(core.clj:113)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:626)
at compojure.core$routes$fn25839.invoke(core.clj:118)
at compojure.core$routing$fn25835.invoke(core.clj:113)
at clojure.core$some.invoke(core.clj:2515)
at compojure.core$routing.doInvoke(core.clj:113)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:626)
at compojure.core$routes$fn25839.invoke(core.clj:118)
at api.vbucket$wrap_vbucket$fn__21857.invoke(vbucket.clj:73)
at api.route$wrap_detect_user_agent$fn26912.invoke(route.clj:411)
at api.route$wrap_ensure_session$fn26892.invoke(route.clj:383)
at ring.middleware.permacookie$wrap_permacookie$fn__26559.invoke(permacookie.clj:35)
at ring.middleware.format_params$wrap_format_params$fn26261.invoke(format_params.clj:113)
at ring.middleware.format_params$wrap_format_params$fn26261.invoke(format_params.clj:113)
at ring.middleware.format_response$wrap_format_response$fn26379.invoke(format_response.clj:174)
at ring.middleware.jsonp$wrap_json_with_padding$fn26487.invoke(jsonp.clj:63)
at api.session$wrap_session$fn__12280.invoke(session.clj:105)
at api.route$wrap_record_new_session$fn26882.invoke(route.clj:329)
at api.vbucket$wrap_record_vbucket_assignment$fn21850.invoke(vbucket.clj:27)
at api.controllers.offers$wrap_record_rco_events$fn__22291.invoke(offers.clj:262)
at ring.middleware.cookies$wrap_cookies$fn12184.invoke(cookies.clj:156)
at api.route$wrap_request_logging$fn26843.invoke(route.clj:260)
at ring.middleware.keyword_params$wrap_keyword_params$fn26007.invoke(keyword_params.clj:35)
at ring.middleware.multipart_params$wrap_multipart_params$fn26085.invoke(multipart_params.clj:118)
at ring.middleware.params$wrap_params$fn__25980.invoke(params.clj:64)
at ring.middleware.nested_params$wrap_nested_params$fn26049.invoke(nested_params.clj:84)
at api.route$wrap_token$fn26916.invoke(route.clj:422)
at api.route$wrap_save_the_raw_body$fn26872.invoke(route.clj:311)
at api.route$wrap_argument_exception$fn26853.invoke(route.clj:282)
at api.route$wrap_stacktrace$fn__26862.invoke(route.clj:292)
at ring.middleware.gzip$wrap_gzip$fn26524.invoke(gzip.clj:94)
at ring.middleware.content_type$wrap_content_type$fn25878.invoke(content_type.clj:30)
at api.route$wrap_cloudwatch$fn26839.invoke(route.clj:255)
at compojure.core$routing$fn25835.invoke(core.clj:113)
at clojure.core$some.invoke(core.clj:2515)
at compojure.core$routing.doInvoke(core.clj:113)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:626)
at compojure.core$routes$fn25839.invoke(core.clj:118)
at org.httpkit.server.HttpHandler.run(RingHandler.java:91)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)