forked from AdaGold/oo-ride-share
-
Notifications
You must be signed in to change notification settings - Fork 29
Space - Jessica, Nikki, Katie #3
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
Open
seaweeddol
wants to merge
34
commits into
Ada-C13:master
Choose a base branch
from
vnikki13:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
97a6ceb
update to correct ruby version
vnikki13 ed00bf1
added tests for Wave 1.1 - upgrading times
vnikki13 1d50fa3
calculate specific time durations of trips using Time class
vnikki13 a35adce
updated ruby file gem
vnikki13 96f586a
write tests for net_expenditures method
vnikki13 2284776
create net_expenditures method
vnikki13 ecb7aa6
Made a Driver class that initiates and created from_csv method
vnikki13 4f1fc16
made a total_time_spent method
vnikki13 99844bf
made tests for passenger total_time_spent method
vnikki13 dc479f3
Made test run
vnikki13 79b32c1
made driver tests work
vnikki13 b2ff292
add add_trip method and defaulted status to sym
vnikki13 fe156ae
added driver_id and driver attributes and updated connect method
vnikki13 84b0f62
called driver.load_all, updated connect method, and added a find_driv…
vnikki13 f668972
updated tests to reflect changes
vnikki13 48d8e8c
updated tests to reflect changes
vnikki13 54e8bbe
add tests for total_revenue method
vnikki13 c3bd8e1
add average_rating and total_revenue methods
vnikki13 1d665b9
add test for request_trip method
vnikki13 8f5ac75
begin writing request_trip method
vnikki13 132481e
made status writeable
seaweeddol 914b711
added if statement to check if nil for end_time and rating
seaweeddol 8b2a7fd
updated request_trip arguments to return new Trip correctly and set d…
seaweeddol 2c34fc1
updated from Class method to instance method
seaweeddol c003e65
added tests for average_rating and total_revenue when there are in pr…
seaweeddol 38e661e
created tests for TripDispatcher request_trip method
seaweeddol caca236
complete all requirements for TripDispatcher request_trip method
seaweeddol 9e0c9c6
updated average_rating and total_revenue methods to account for nil v…
seaweeddol 4ee3082
added helper method trip_in_progress
seaweeddol cf52051
added pick_driver_for_trip helper method and added new logic for wave 4
seaweeddol 31dab54
called pick_driver_for_trip instead of loop to pick first avail driver
seaweeddol 3d9e725
changed tests to use test data and created tests for new pick_driver_…
seaweeddol c709b19
cleaned and refactored code
seaweeddol 4838654
fix order of variables to match trips.csv order
seaweeddol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| source 'http://rubygems.org' | ||
|
|
||
| ruby '2.5.5' | ||
| ruby '2.6.5' | ||
|
|
||
| gem 'rake' | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| GEM | ||
| remote: http://rubygems.org/ | ||
| specs: | ||
| ansi (1.5.0) | ||
| awesome_print (1.8.0) | ||
| builder (3.2.4) | ||
| csv (3.1.2) | ||
| minitest (5.14.0) | ||
| minitest-reporters (1.4.2) | ||
| ansi | ||
| builder | ||
| minitest (>= 5.0) | ||
| ruby-progressbar | ||
| minitest-skip (0.0.1) | ||
| minitest (~> 5.0) | ||
| rake (13.0.1) | ||
| ruby-progressbar (1.10.1) | ||
|
|
||
| PLATFORMS | ||
| ruby | ||
|
|
||
| DEPENDENCIES | ||
| awesome_print | ||
| csv | ||
| minitest | ||
| minitest-reporters | ||
| minitest-skip | ||
| rake | ||
|
|
||
| RUBY VERSION | ||
| ruby 2.5.5p157 | ||
|
|
||
| BUNDLED WITH | ||
| 2.1.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| require 'csv' | ||
| require_relative 'csv_record' | ||
|
|
||
| module RideShare | ||
| class Driver < CsvRecord | ||
| attr_reader :id, :name, :vin, :trips | ||
| attr_accessor :status | ||
|
|
||
| def initialize( | ||
| id:, | ||
| name:, | ||
| vin:, | ||
| status: :AVAILABLE, | ||
| trips: nil | ||
| ) | ||
| super(id) | ||
|
|
||
| (vin.length == 17) ? (@vin = vin) : (raise ArgumentError) | ||
| [:AVAILABLE, :UNAVAILABLE].include?(status) ? (@status = status.to_sym) : (raise ArgumentError) | ||
|
|
||
| @name = name | ||
| @trips = trips || [] | ||
|
|
||
| end | ||
|
|
||
| def trip_in_progress(trip) | ||
| @status = :UNAVAILABLE | ||
| add_trip(trip) | ||
| end | ||
|
|
||
| def add_trip(trip) | ||
| @trips << trip | ||
| end | ||
|
|
||
| def average_rating | ||
| # get all trips where rating is not nil | ||
| completed_trips = trips.select{ |trip| trip.rating != nil } | ||
|
|
||
| trip_ratings = completed_trips.map { |trip| trip.rating.to_f } | ||
|
|
||
| return 0 if trip_ratings.length == 0 | ||
| return trip_ratings.sum / trip_ratings.length | ||
| end | ||
|
|
||
| def total_revenue | ||
| # get all trips where cost is not nil and is more than 1.65 | ||
| completed_trips = trips.select{ |trip| trip.cost != nil && trip.cost > 1.65 } | ||
|
|
||
| trip_revenues = completed_trips.map { |trip| (trip.cost - 1.65) * 0.8 } | ||
|
|
||
| return trip_revenues.sum.round(2) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def self.from_csv(record) | ||
| return new( | ||
| id: record[:id], | ||
| name: record[:name], | ||
| vin: record[:vin], | ||
| status: record[:status].to_sym | ||
| ) | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Awesome!