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

Earth/Ting-Yi/Taylor #9

Open
wants to merge 64 commits into
base: master
Choose a base branch
from

Conversation

TaylorMililani
Copy link

@TaylorMililani TaylorMililani commented Nov 6, 2020

Assignment Submission: Rideshare Rails

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions. These questions should be answered by all team members together, not by a single teammate.

Reflection

Prompt Response
Describe the types of entity relationships you set up in your project and why you set up the relationships that way We set up trip belongs to both passenger and driver, and passenger and driver both have many trips.
Describe the role of model validations in your application Prevents the creation of invalid data.
How did your team break up the work to be done? We split up Passenger and Driver tasks, and did most Trip tasks together.
What features did you choose to prioritize in your project, and what features, if any, did you have to set aside to meet the deadline? We prioritized required functionality and also the complete trip feature, while we set css to the back burner.
What was one thing that your team collectively gained more clarity on after completing this assignment? Relationships between models, model tests, and nested routes.
What are two discussion points that you and your team discussed when giving/receiving feedback from each other that you would be willing to share? We talked about how we both prefer direct communication.
Optional: What is the URL of your deployed Heroku app? https://desolate-atoll-20205.herokuapp.com/

TaylorMililani and others added 30 commits November 3, 2020 15:20
TaylorMililani and others added 29 commits November 5, 2020 14:04
Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Rideshare Rails

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Practices collaborating with git, and all team members contribute git commits and best git practices ✔️
Demonstrates understanding of relationships by giving accurate answers to the reflection questions and appropriate code in the models ✔️
Logic to calculate a driver's average rating and total earnings is located in the model, and it has unit tests ✔️
There are reasonable tests to test the validation requirements for all models ✔️
There are reasonable tests to test the relationship requirements for all models ✔️
There are reasonable tests to test the controller actions for all controllers ✔️
The app has an attractive and usable user interface ✔️, really nice looking!
The app uses/is compatible with database seeds ✔️
Router code is clean: uses resources and RESTful routes ⚠️ Oops, you've got some extra routes defined in your resources. See my inline comments.

Functional Requirements

Functional Requirement yes/no
On the passenger's details page, I want to be able to see total charged, list of trips, a link to edit, and delete ✔️
When adding a new passenger, I want to see errors and validations that show that a passenger must be provided a name and a phone number, so that I cannot make a passenger without name or phone number ✔️
On the passenger's details page, I can create a new trip for this passenger, with an assigned driver and no rating ✔️
On the driver's details page, I want to be able to see total earnings, average rating, list of trips, a link to edit, and delete ✔️
When adding a new driver, I want to see errors and validations that show that a driver must be provided a name and VIN, so that I cannot make a driver without name or VIN ✔️
On the trip's detail page, I want to be able to view details, assign a rating, navigate to the trip's passenger, driver, a link to edit, and delete ✔️, except that I can't delete unless the driver and passenger are already deleted... odd.

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 8+ in Code Review && 5+ in Functional Requirements 💚

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

Summary

Nice work Tiny-Yi & Taylor. This is truly outstanding. Take a look at my comments and let me know what questions you have.

redirect_to driver_path(id: @driver[:id])
return
else
render :new, status: :bad_request

Choose a reason for hiding this comment

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

👍 Nice!

redirect_to drivers_path
return
elsif !(@driver.isactive)
render :file => "#{Rails.root}/public/404.html", layout: false, status: :not_found

Choose a reason for hiding this comment

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

😁 Well done

Comment on lines +12 to +20
every_costs.each do |trip|
if trip.cost <= 1.65 * 100
sum += trip.cost * 0.8
else
sum += (trip.cost - 1.65 * 100) * 0.8
end
end
return (sum / 100).round(2)
end

Choose a reason for hiding this comment

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

Just a note that you can use enumerables as well.

Suggested change
every_costs.each do |trip|
if trip.cost <= 1.65 * 100
sum += trip.cost * 0.8
else
sum += (trip.cost - 1.65 * 100) * 0.8
end
end
return (sum / 100).round(2)
end
sum = every_costs.sum do |trip|
if trip.cost.nil?
0
elsif trip.cost < 1.65 * 100
trip.cost * 0.8
else
(trip.cost - 1.65 * 100) * 0.8
end

Comment on lines +22 to +28
def ave_rating
rating_by_passengers = self.trips.where.not(rating: nil)
return nil if rating_by_passengers.empty?

sum = rating_by_passengers.sum { |trip| trip.rating}
return (sum / rating_by_passengers.count.to_f).round(1)
end

Choose a reason for hiding this comment

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

👍

validates :name, presence: true
validates :phone_num, presence: true

def total_spent

Choose a reason for hiding this comment

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

Just a note that you can do an enumerable here as well.

end
end

describe "complete_trip" do

Choose a reason for hiding this comment

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

I would also include a test to verify that the driver's average rating changed appropriately.

end

resources :passengers do
resources :trips, only: [:index, :new, :create]

Choose a reason for hiding this comment

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

Do you really need the new trip form? You can just automatically create a trip from the link.


root 'homepages#index'
resources :drivers do
resources :trips, only: [:index]

Choose a reason for hiding this comment

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

Do you use this nested route?

Comment on lines +13 to +16
resources :trips, except: [:index] do
resources :drivers, only: [:index]
resources :passengers, only: [:index]
end

Choose a reason for hiding this comment

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

You really don't need all these routes. Think about this a bit.


driver = @trip.driver
passenger = @trip.passenger
if !(driver.isactive) && !(passenger.isactive)

Choose a reason for hiding this comment

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

I'm unclear why you couldn't delete a trip if the passenger or driver was active?

Choose a reason for hiding this comment

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

If the trip is deletable when either driver or passenger is still active, then either of them couldn't see the trip after it's been deleted when they want to see it. If I was the user, I still want to see my trip, that was what I thought back to that moment. Does it make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants