-
Notifications
You must be signed in to change notification settings - Fork 28
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
Sammi Jo & Jazz 00 Ride Share #19
base: master
Are you sure you want to change the base?
Conversation
Ride ShareWhat We're Looking For
|
return 0 | ||
else | ||
sum = 0 | ||
@driven_trips.each do |trip| |
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.
This would need to be adapted to incomplete trips.
complete_trips = @driven_trips.select { |trip| trip.rating != nil }
sum = complete_trips.sum_by { |trip| trip.rating }
return sum.to_f / complete_trips.length
def total_revenue | ||
sum = 0 | ||
@driven_trips.each do |trip| | ||
if trip.cost == nil |
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.
👍
return revenue = (sum * 0.80) | ||
end | ||
|
||
def net_expenditures # driver.net_expenditures |
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.
👍
available = @drivers.find { |driver| | ||
driver.status == :AVAILABLE && driver.id != user_id | ||
} | ||
if available == nil |
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.
available
can't be nil
instead you should check to see if available.empty?
if delay < DELAY_LIMIT | ||
puts "#{exception.message} Please wait. (current delay @ #{delay}" \ | ||
" of #{DELAY_LIMIT})" | ||
sleep(5) |
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 sleep
?
driver = RideShare::Driver.new(id: 54, name: "Rogers Bartell IV", | ||
vin: "1C9EVBRM0YBC564DZ") | ||
vehicle_id: "1C9EVBRM0YBC564DZ") | ||
expect(driver.average_rating).must_equal 0 | ||
end | ||
|
||
it "correctly calculates the average rating" do |
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.
You also need a test here for handling the average with some incomplete trips.
expect((dispatcher.find_driver(5).driven_trips).length).must_equal (old_number_of_driven_trips + 1) | ||
end | ||
|
||
it "correctly handles NO AVILABLE DRIVERS situation" do |
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.
🥇
@@ -59,4 +58,42 @@ | |||
end | |||
end | |||
end | |||
|
|||
describe "net expenditures" do |
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.
You should also test when there are no trips for the user.
OO Ride Share
Congratulations! You're submitting your assignment!
Comprehension Questions
User
andDriver