-
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
Kat F. & Leanne R. Ride Share OOD #12
base: master
Are you sure you want to change the base?
Conversation
Our recent commits aren't showing up though we had pushed them multiple times... |
@leannerivera Come by and show me what's happening and we can look for your missing commits. |
Ride ShareWhat We're Looking For
|
def average_rating | ||
ratings = 0 | ||
count = 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.
You should have something added to deal with incomplete trips
completed_trips = @driven_trips.select {|trip| trip.end_time != nil }
And then only use the completed_trips
.
The same concept can apply to average_rating
, total_revenue
etc
count += 1 | ||
end | ||
|
||
if ratings = 0 || count = 0 |
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.
Look at this if statement.
- You're using
=
not==
- This doesn't seem to serve much of a purpose.
|
||
total_revenue += (trip.cost - 1.65) | ||
end | ||
return (total_revenue/ 0.8).round(2) |
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're increasing the total revenue by 1.25 times?
def net_expenditures | ||
trip_costs = 0 | ||
# driver/passenger trip cost - total_revenue | ||
if TripDispatcher.trips.passenger == self.id |
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.
What is this doing?
You can use the superclass method in this:
return super - self.total_revenue
"PassengerID=#{passenger&.id.inspect}>" | ||
|
||
def trip_to_seconds | ||
midnight = Time.local(2018,8,26,0,0,0) |
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 could also be done as:
return end_time - start_time
|
||
def net_expenditures | ||
total = 0 | ||
self.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.
For wave 3 you would need to adapt this to incomplete trips.
completed_trips = self.trips.select { |trip| trip.end_time != nil }
end | ||
|
||
def total_time_spent | ||
@passenger.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.
For wave 3 you would also need to filter the list for only completed trips
@passenger.trips.each do |trip| | ||
t1 = Time.parse(trip.start_time) | ||
t2 = Time.parse(trip.end_time) | ||
duration += sprintf("%0.02f", (t2 - t1) % 60) |
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 should return a number, not a string.
|
||
it "changes driver status to unavailable" do | ||
request = @dispatcher.request_trip(6) | ||
expect(request.driver.status).must_equal :UNAVAILABLE |
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 verify the driver was available before the request_trip
end | ||
|
||
it "raises an error if there are no available drivers" do | ||
dispatcher = RideShare::TripDispatcher.new(USER_TEST_FILE, |
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.
smart 👍
OO Ride Share
Congratulations! You're submitting your assignment!
Comprehension Questions
User
andDriver