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 - Maha & Olga #30

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

Earth - Maha & Olga #30

wants to merge 62 commits into from

Conversation

OlgaSe
Copy link

@OlgaSe OlgaSe commented Nov 7, 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 Trip has one driver and passenger (one-to-one relationship) and driver and passenger can have one trip (one-many relationship).
Describe the role of model validations in your application Checking all required field to create a model instance.
How did your team break up the work to be done? We worked separately on models and controllers, pushed to the main branch and had meetings to discuss progress and issues.
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 focused on the required functionality and making our project work. We didn't address design.
What was one thing that your team collectively gained more clarity on after completing this assignment? Model relationships, testing models, resolving git merging conflicts.
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? 5 stars for collaboration🥇
Optional: What is the URL of your deployed Heroku app? no

OlgaSe and others added 30 commits November 3, 2020 17:57
…ller. Added a new view file to passegner that contains a form to create a new task.
OlgaSe and others added 29 commits November 5, 2020 18:53
Added tests for trip controller, all except destroy
…isplay if trip has no cost, added bad_request to update action in the trip controller
…per method to instanciate trip, driver and passenger for tests
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 ✔️, basic, but it works
The app uses/is compatible with database seeds ✔️
Router code is clean: uses resources and RESTful routes ✔️, but see my one comment

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 ✔️, you see errors on the creation of a passenger, but not updating a passenger.
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 ✔️, you don't see validations with the edit action.
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) 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
Descriptive/Readable
Concise
Logical/Organized

Summary

This is pretty well done, you hit the main learning goals. You also had some pretty good tests. I had a few suggestions on displaying validation errors, and using enumerables in model methods.

redirect_to driver_path @driver.id
return
else # if save is failed
render :new, status: :bad_request #shows new book form again

Choose a reason for hiding this comment

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

Book?

Suggested change
render :new, status: :bad_request #shows new book form again
render :new, status: :bad_request

redirect_to passenger_path # go to the passenger details page
return
else # save failed
render :edit # show the new passenger form view again

Choose a reason for hiding this comment

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

Suggested change
render :edit # show the new passenger form view again
render :edit, status: :bad_request # show the new passenger form view again

Comment on lines +8 to +16
sum = 0
trips.each do |trip|
if trip.cost < 0
return 0
else
sum += (trip.cost - 165) * 0.8
end
end
return sum.round(2)

Choose a reason for hiding this comment

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

Just a suggestion to use an enumerable.

Suggested change
sum = 0
trips.each do |trip|
if trip.cost < 0
return 0
else
sum += (trip.cost - 165) * 0.8
end
end
return sum.round(2)
sum = trips.sum do |trip|
trip.cost < 0 ? 0 : (trip.cost - 165) * 0.8
end
return sum.round(2)

@@ -0,0 +1,13 @@
<h2> New driver page</h2>

<% if @driver.errors.any? %>

Choose a reason for hiding this comment

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

Why not put this in the partial?

@@ -0,0 +1,28 @@
<!DOCTYPE html>

Choose a reason for hiding this comment

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

Nice work with the template

Comment on lines +103 to +109
# describe "can go online" do
# # Your code here
# end
#
# describe "can go offline" do
# # Your code here
# end

Choose a reason for hiding this comment

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

So no test or method to go online/offline.

describe "relationships" do
# Your tests go here
end
it "can have one passenger:many to 1" do

Choose a reason for hiding this comment

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

Suggested change
it "can have one passenger:many to 1" do
it "belongs to a Passenger" do

# Tests for methods you create should go here
describe "custom methods" do
# Your tests here
it "must have a cost" do

Choose a reason for hiding this comment

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

You also need to test the numericality.

I would also test that a trip is required to have a passenger and a driver.

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

Choose a reason for hiding this comment

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

You don't need all the RESTful routes for trips here since you are doing index and create nested under passengers.

<%= link_to 'Edit', edit_driver_path(@driver) %>
<%= link_to 'Delete', @driver, method: :delete, data: { confirm: 'Are you sure?' } %>

<table id='trips-table' class="table table-hover">

Choose a reason for hiding this comment

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

You can convert this content to a partial. Then you can display the same table anywhere you list trips.

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