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

[1501] Availability Overhaul #1538

Merged
merged 1 commit into from
May 17, 2016
Merged

Conversation

esoterik
Copy link
Collaborator

@esoterik esoterik commented Apr 5, 2016

Resolves #1501

This is not finished yet, but it would be great if someone could look over the counter cache implementation and the changes to the reservation and equipment model models!

@@ -14,6 +14,7 @@ task run_daily_tasks: :environment do
Rake::Task['email_checkout_reminder'].invoke
Rake::Task['delete_old_blackouts'].invoke
Rake::Task['delete_missed_reservations'].invoke
Reservation.counter_culture_fix_counts
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a leftover from a gem that I'm not using anymore and should be deleted

@orenyk
Copy link
Contributor

orenyk commented Apr 5, 2016

@esoterik reviewed a bunch of it, the counter cache stuff looks really good to me, nice work! A few comments on the specs but otherwise that portion of the code was really solid. Did you want me to review the rest of the specs or are they still in progress? Done for now, let me know!

@esoterik
Copy link
Collaborator Author

esoterik commented Apr 8, 2016

All of the new specs should be complete, it'd be great if you could take a look!

@esoterik
Copy link
Collaborator Author

esoterik commented Apr 9, 2016

Actually nevermind, I've changed somethings and will push the update soon

@esoterik
Copy link
Collaborator Author

esoterik commented Apr 9, 2016

Okay, the new equipment model specs are tentatively complete; no need for any rereview at the moment

@orenyk
Copy link
Contributor

orenyk commented Apr 10, 2016

@esoterik to confirm, you want to wait until this is finished for a complete re-review? Let me know, thanks!

@esoterik
Copy link
Collaborator Author

The tests that failed are due to the intermittently failing tests, this is ready for rereview

@@ -19,6 +19,14 @@ class Reservation < ActiveRecord::Base
validate :status_final_state
validate :not_in_past, :available, :check_banned, on: :create

# conditional counter cache for overdue reservations
after_update :increment_cache, if: :checked_out?
after_update :decrement_cache, if: :overdue
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

need to make sure that this works for edited overdue reservations (as in #1479)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done!

@esoterik
Copy link
Collaborator Author

Okay, I cleaned up the tests and will look into the intermittent failures later

@esoterik
Copy link
Collaborator Author

I suspect that the issues might have to do with the use of before(:all) (see the end of this blog post http://tomdallimore.com/blog/taking-the-test-trash-out-with-databasecleaner-and-rspec/)

@esoterik
Copy link
Collaborator Author

Also, rspec bisect (recommended by the testing rails book) is pretty great, though it's pretty slow.

@esoterik
Copy link
Collaborator Author

esoterik commented Apr 28, 2016

Okay, the intermittent failure should be fixed (seed 1699 and 52941)!

@orenyk
Copy link
Contributor

orenyk commented Apr 28, 2016

Awesome! Did rspec bispect find anything else?

@esoterik
Copy link
Collaborator Author

Not for those seeds

@orenyk
Copy link
Contributor

orenyk commented Apr 28, 2016

Just read the blog post you linked to, we definitely need to get rid of all the before(:all) calls that don't have an associated after(:all) cleanup and probably revamp our DatabaseCleaner config as well. Let's make that the focus of #1514.

end

# figure out the qualitative status of this model's items
def availability(date)
num = available_count(date)
num = num_available_on(date)
total = equipment_items.active.count
if num == 0 then 'none'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

leq

@orenyk
Copy link
Contributor

orenyk commented May 3, 2016

Alright I think we can :shipit:, let's merge and rebase onto the latest master!

@esoterik
Copy link
Collaborator Author

Finally got around to squashing this!

count += 1 if r.overdue && r.equipment_model_id == model_id
end
count
def active?
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used anywhere? Searching across the diff seems to indicate that it wasn't...

@orenyk
Copy link
Contributor

orenyk commented May 16, 2016

Looks good, just one final inline comment that came up when I took a last look-through, let me know about it and we can merge!

Resolves #1501
  - Availability methods all work as expected
  - Adds counter cache on equipment models for current overdue reservations
  - Reservation factory trait :past allows for creation of past
    reservations without skipping validations
  - New reservation model methods for counting reservations, attribute
    checking, and checking for overlapping
@esoterik esoterik force-pushed the 1501_eq_availability_improvement branch from e251561 to f7440c0 Compare May 16, 2016 22:48
@esoterik
Copy link
Collaborator Author

got rid of that method; should be actually ready now

@orenyk
Copy link
Contributor

orenyk commented May 17, 2016

Great! Just goes to show, you can't review code too many times 😛. Merging, please update the CHANGELOG in #1548, thanks!

@orenyk orenyk merged commit 5e73c7d into master May 17, 2016
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.

2 participants