Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

[Fix Cart Latency] Remove CartReservations! #587

Merged
merged 35 commits into from
Jul 8, 2014

Conversation

squidgetx
Copy link
Contributor

This PR removes CartReservations entirely from the project. Most calls to CartReservations have been replaced with cart.prepare_all, which builds reservations out of the contents of the cart without needing any interaction with the database

@squidgetx squidgetx mentioned this pull request Jun 26, 2014
2 tasks
@squidgetx squidgetx added this to the 3.3.0 milestone Jun 26, 2014
@squidgetx squidgetx modified the milestones: 3.4.0, 3.3.0 Jun 27, 2014
@mnquintana mnquintana mentioned this pull request Jul 1, 2014
@squidgetx
Copy link
Contributor Author

  • Cart model and spec
  • Convert cart to be stored in CookieSession as opposed to regular session
  • Remove cartReservation model and entry in database
  • Disable (do not remove!) autovalidations from cart date form
  • Re-route make-reservation button to new reservation view
  • Refactor new controller action to use cart.prepareAll and validateSet

@squidgetx
Copy link
Contributor Author

Current state of the branch

  • Cart Reservations have been almost completely removed
  • Cart has been refactored and new method prepare_all has been added
  • Cart no longer autovalidates on date changes or item adding
  • Most functionality remains despite this somewhat major change

end

# If the dates were illogical, sets due date to day after start date
def fix_due_date
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to get rid of fix_due_date? it's true that validations will now catch this, but if we leave this we'll need to fix it in regards to hard/soft reservations in #573.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about adding something to fix_cart_date in application_controller (line 112) to handle the due date as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented via oren's suggestion; fix due date is back in the cart model and is called inthe application controller

@dgoerger dgoerger mentioned this pull request Jul 7, 2014
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.

Reservations::Application.config.session_store :active_record_store
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take this out and file a separate issue, so we can deal with the delicacies of cookies encryption and whatnot. :-)

FactoryGirl.create(:invalid_cart_reservation).id ]}
items { { FactoryGirl.create(:equipment_model).id => 1} }
start_date Date.today
due_date Date.today + 100.day
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might it be possible to take the max_length variable and add to that, instead of hard-coding 100.days here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, it's currently hard-coded into the factory as 10 days (see /spec/factories/equipment_models.rb) but better to refer to the equipment model rather than an arbitrary constant.

@dgoerger
Copy link
Contributor

dgoerger commented Jul 7, 2014

otherwise I think this looks good. please see above inline comments.

cart.start_date = Date.strptime(params[:cart][:start_date_cart],'%m/%d/%Y')
cart.due_date = Date.strptime(params[:cart][:due_date_cart],'%m/%d/%Y')
cart.reserver_id = params[:reserver_id]
rescue ArgumentError
cart.set_start_date(Date.today)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need to change this to cart.start_date as well? set_start_date is still a method of Cart but here we're calling it on the session cart.

@orenyk
Copy link
Contributor

orenyk commented Jul 8, 2014

Added a few inline comments as well, otherwise looks good to me!

EDIT: Does this include an updated schema.rb? Git tells me that it's been modified after running rake db:migrate on this branch.

@squidgetx
Copy link
Contributor Author

Good catches everybody, I'll get to work on it tomorrow morning.

@orenyk this branch includes a migration (to remove the cart reservations table) but not an updated schema. Should I put that in as well?

@orenyk
Copy link
Contributor

orenyk commented Jul 8, 2014

I'm not sure what best practice is; the current schema in development seems to be broken regardless (see #636) but the auto-generated comment at the top of the file says # It's strongly recommended to check this file into your version control system.

I think we should try to keep the comment as up-to-date as possible, so every time you add a migration we should update the schema file as well.

@squidgetx
Copy link
Contributor Author

  • Fix due date needs to be implemented somehow, I thought it was handled in the jQuery but it appears not to be
  • improve factory
  • remove all calls to set_start_date
  • Catch <= 0
  • schema

@dgoerger
Copy link
Contributor

dgoerger commented Jul 8, 2014

grep for removed methods turns up clean, changes from review comments look good. please proceed with merge. :)

squidgetx added a commit that referenced this pull request Jul 8, 2014
[Fix Cart Latency] Remove CartReservations!
@squidgetx squidgetx merged commit 6c5e673 into development Jul 8, 2014
@orenyk
Copy link
Contributor

orenyk commented Jul 8, 2014

nice work!

@squidgetx squidgetx deleted the 587_fix_cart_latency branch July 11, 2014 15:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants