Skip to content
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

🐛 Marketplace: ActionView::Template::Error: undefined method `strftime' for "BETWEEN 4:30 PM - 6PM":String #1265

Closed
sentry-io bot opened this issue Mar 25, 2023 · 5 comments · Fixed by #1266
Assignees
Labels
🐞 bug Something isn't working

Comments

@sentry-io
Copy link

sentry-io bot commented Mar 25, 2023

NoMethodError: undefined method `strftime' for "BETWEEN 4:30 PM - 6PM":String

            value&.strftime("%Y-%m-%dT%T")
                 ^^^^^^^^^^
Did you mean?  strip
  app/views/application/_datetime_field.html.erb:3:
    <%= form.datetime_field attribute %>
  app/furniture/marketplace/carts/_cart.html.erb:6:
    <%= render "datetime_field", attribute: :delivery_window, form: cart_form, disabled?: cart.marketplace.delivery_window.present? %>
  app/furniture/marketplace/carts/_cart.html.erb:4:
    <%= form_with model: cart.location do |cart_form| %>
  app/furniture/marketplace/marketplaces/_marketplace.html.erb:9:
    <%= render cart %>
  app/views/furnitures/_furniture.html.erb:34:
    <%= render furniture.furniture %>
...
(239 additional frame(s) were not displayed)

ActionView::Template::Error: undefined method `strftime' for "BETWEEN 4:30 PM - 6PM":String

            value&.strftime("%Y-%m-%dT%T")
                 ^^^^^^^^^^
Did you mean?  strip
@anaulin anaulin self-assigned this Mar 25, 2023
@anaulin anaulin changed the title ActionView::Template::Error: undefined method `strftime' for "BETWEEN 4:30 PM - 6PM":String 🐛 Marketplace: ActionView::Template::Error: undefined method `strftime' for "BETWEEN 4:30 PM - 6PM":String Mar 25, 2023
@anaulin
Copy link
Member

anaulin commented Mar 25, 2023

This was introduced when we changed the expected type of Marketplace#delivery_window in #1251, but did not migrate the existing data in the https://piikup-sandbox.zinc.coop instance.

@anaulin
Copy link
Member

anaulin commented Mar 25, 2023

we are going from strings that mostly look like they were meant to be mostly time intervals, to one DateTime value, so there is really no good way to migrate this data.

I'm going to at least try to parse the existing string-type delivery windows to Dates, which will stop the 500s and whill gives us something like:

> m = Marketplace::Marketplace.all.select { |m| m.delivery_window.present? }
> m.map { |m| [m.id, m.delivery_window, begin DateTime.parse(m.delivery_window) rescue nil end] }
=> 
[["3c2df6a3-f6b0-4e4e-b137-79860e8b28c9", "as needed", nil],                                                                      
 ["f07fe90e-5a1d-43ca-aca2-fb8dfa70d915", "Same day 3pm - 6pm in Oakland , Berkeley and Alameda", Sat, 25 Mar 2023 15:00:00 +0000],
 ["dfb19803-7131-4443-ad6d-80cbc1f4571e", "Monday from 10AM to 2PM", Mon, 20 Mar 2023 10:00:00 +0000],                            
 ["0025198b-2196-4a26-96b1-921fb325ba84", "FRIDAY BETWEEN 3PM - 6PM", Fri, 24 Mar 2023 15:00:00 +0000],                           
 ["4bee9409-3ffa-4e49-b002-bbe3d63887fe", "BETWEEN 4:30 PM - 6PM", Sat, 25 Mar 2023 16:30:00 +0000]]

It feels like delivery windows really need to be a time interval, and we probably want a list of them in each Marketplace.

@anaulin
Copy link
Member

anaulin commented Mar 25, 2023

I have fixed the stored delivery windows, but we now have a different bug, where the cart returns its delivery window as a string:

undefined method `strftime' for "2023-03-20T10:00:00.000+00:00":String

            value&.strftime("%Y-%m-%dT%T")
                 ^^^^^^^^^^
Did you mean?  strip

@zspencer
Copy link
Member

I left some comments in the other P.R. but one thing we want to keep in mind is that the Delivery Window is supposed to be pretty flexible; like they do want to preserve the ability to enter a plain string describing the delivery constraints until we get to the point where we've modeled it well.

So, Carts should have a Delivery object that is the time they would like to receive the items, and the Marketplace should have a DeliveryWindow?DeliverySchedule? Which is used to indicate what options a Shopper has when ordering.

@zspencer zspencer added the 🐞 bug Something isn't working label Mar 27, 2023
zspencer added a commit that referenced this issue Mar 27, 2023
- https://zinc-collective.sentry.io/issues/4031191037/?project=6052513
- #1265
- #1185
- #1269

So, it turns out the reason we were getting these errors was because I
had not made the form picker smart enough to use the string value when a
delivery window was not present.

Now it is!

Also, reverting the StoreModel stuff because it did not seem to fix the
problem and I can't figure out why it's not working :'(
@zspencer
Copy link
Member

zspencer commented Mar 28, 2023

zspencer added a commit that referenced this issue Mar 28, 2023
- https://zinc-collective.sentry.io/issues/4031191037/?project=6052513
- #1265
- #1185
- #1269

So, it turns out the reason we were getting these errors was because I
had not made the form picker smart enough to use the string value when a
delivery window was not present.

Now it is!

Also, reverting the StoreModel stuff because it did not seem to fix the
problem and I can't figure out why it's not working :'(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
2 participants