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

Fire - Ida Goitom and Earth - Christina Minh #10

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

Conversation

christinaminh
Copy link

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 Driver and Passenger has_many Trips and Trips belongs_to Driver and Passenger. We set up the relationships so we can connect passenger_id and driver_id to passenger and driver, respectively. This makes it easier to retrieve that information about related objects.
Describe the role of model validations in your application The business logic of the program. We are able to calculate the average rating, total earnings and sift through data to find information. With validations, we’re able to ensure the model field’s follow a format we want, particularly when a user is creating/editing a new Passenger, Driver, or Trip.
How did your team break up the work to be done? We split up the work to complete each controller and their corresponding model and views. We also split up the layout, homepage, and views.
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? Prioritized basic functionality first such as controller actions, routes and testing was completed properly. Then went into exceptions and validations and drying up the code. Then added styling.
What was one thing that your team collectively gained more clarity on after completing this assignment? We gained more clarity on testing as there were six pages of tests to be done.
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 regularly updated each other, split up the workload and asked questions when needed.
Optional: What is the URL of your deployed Heroku app? N/A

christinaminh and others added 30 commits November 2, 2020 18:54
… index, new, and show actions for PassengersController, and partial view of form
…n'). Passenger#total_charged with tests. Changed Passenger's show.html.erb to show total charged and list trips(date).
… that users must enter provide a name and vin
christinaminh and others added 29 commits November 5, 2020 18:21
…refactor. Changed TripsController#new accordingly.
Copy link

@tildeee tildeee 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 This pains me to take away this checkmark, since your model tests otherwise are really well-written and thorough... But technically y'all didn't test toggle_status, and truthfully I would expect additional tests for the custom methods to test edge cases, such as what if the driver doesn't have trips.
There are reasonable tests to test the validation requirements for all models ✔️, your trip validation tests are particularly amazing!
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 ✔️
The app uses/is compatible with database seeds ✔️
Router code is clean: uses resources and RESTful routes ✔️

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 Doesn't automatically assign a driver, but brings user to a form with a drop down. The drop down only lists available drivers!
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 ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 7+ in Code Review && 5+ in Functional Requirements ✔️
Yellow (Approaches Standards) 5+ in Code Review && 4+ in Functional Requirements, or the instructor judges that this project needs special attention
Red (Not at Standard) 0-4 in Code Review or 0-3 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging, or the instructor judges that this project needs special attention

Additional Feedback

Great work on this project, Ida and Christina!

Overall, your code looks great. I'm seriously really impressed and happy with how your model tests are written and how they read.

Overall, I'm adding a few comments to hopefully help code style-- a common theme I saw was having things (variables, methods) that probably could be refactored out. It's good to have things be very clear and organized, but when we have too many things, it'll end up being confusing for your teammates-- your teammates will ask, "do we need this file? Do we use this method?" and the communicate gets harder :(

One other pattern I'm going to point out is-- for a better user experience, now that we know the power of redirects, it may be be better to redirect, instead of head :not_found! This applies to your code in your Drivers, Trips, and Passengers controllers.

Other than that, your project is great-- great work on all of the functionality you two built!

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

@driver = Driver.find_by(id: driver_id)
#
if @driver.nil?
head :not_found
Copy link

Choose a reason for hiding this comment

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

Now that we know the power of redirects, in these cases, it might be best to redirect to a page like the homepage, in case the driver isn't found.

def show
driver_id = params[:id].to_i
@driver = Driver.find_by(id: driver_id)
#
Copy link

Choose a reason for hiding this comment

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

Nitpicking: This is an empty line with a comment, but no comment :) feel free to delete this before submission

Comment on lines +15 to +17
else
render :new
end
Copy link

Choose a reason for hiding this comment

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

Mind your indentation! :)


def edit
@driver = Driver.find_by(id: params[:id])
if @driver.nil?
Copy link

Choose a reason for hiding this comment

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

Similar to above, now that we know the power of redirects, in these cases, it might be best to redirect to a page like the homepage, in case the driver isn't found.

Comment on lines +8 to +10
all_trips = self.trips

all_trips.each do |trip|
Copy link

Choose a reason for hiding this comment

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

Here, the value of all_trips is self.trips, and it's used once... Personally, I love having variables in order to give context, but I personally think that self.trips IS self-explanatory/self-documenting enough, that the code still reads well if we use self.trips directly. Consider using self.trips instead!

Your code might look like this, instead (deleting line 8 as well)

Suggested change
all_trips = self.trips
all_trips.each do |trip|
self.trips.each do |trip|

Comment on lines +25 to +28
total = 0
all_trips.each do |trip|
total += trip.rating.to_f
end
Copy link

Choose a reason for hiding this comment

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

Here, you're summing all of the trip's rating attributes. Consider using something like sum!

Comment on lines +36 to +43
def total_driver_trips
all_trips = self.trips
total_trips = []
all_trips.each do |trip|
total_trips << trip
end
return total_trips
end
Copy link

Choose a reason for hiding this comment

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

I am a little unsure about how this method differs from the original self.trips array. It seems to shovel every trip from self.trips into a new array... Could we get rid of this method, and in the view, use @driver.trips?

Comment on lines +45 to +54
def self.find_available_driver
available_driver = self.find_by(available: true)
return available_driver
end

def toggle_status
self.available = !self.available

return self.save
end
Copy link

Choose a reason for hiding this comment

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

Great helper methods overall!

Comment on lines +1 to +3
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
Copy link

Choose a reason for hiding this comment

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

Nitpicking... I see this file named routes 2.rb. This seems like a mistake? If it is a mistake, you all should feel free to delete that file before submission ;)

resources :drivers do
resources :trips, only: [:index]
end
resources :homepages
Copy link

Choose a reason for hiding this comment

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

y'all probably didn't need all of resources :homepages since there's truly one route that you care about; it'll be best to be selective here!

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