-
Notifications
You must be signed in to change notification settings - Fork 27
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
Panda and Tiger Submission #29
Open
jperezish
wants to merge
4
commits into
RubyoffRails:master
Choose a base branch
from
jperezish: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 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e7f63e2
add 2 more shows to the seed file, update show output format
jperezish 2a29cff
add CLI to ask for day of week, app returns shows that match the prov…
jperezish 2268c9f
create review table, create ui to access a movie review
jperezish f3bd867
update to use DB where query
jperezish 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 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,10 @@ | ||
class CreateReviews < ActiveRecord::Migration | ||
def change | ||
create_table :reviews do |t| | ||
t.string :movie | ||
t.integer :rating | ||
t.string :reviewer | ||
t.string :synopsis | ||
end | ||
end | ||
end |
This file contains 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,7 +1,32 @@ | ||
# Cleaning Out | ||
Network.delete_all | ||
Show.delete_all | ||
amc = Network.create(name: "AMC") | ||
nbc = Network.create(name: "NBC") | ||
Review.delete_all | ||
amc = Network.create(name: "AMC") | ||
nbc = Network.create(name: "NBC") | ||
bravo = Network.create(name: "Bravo") | ||
Show.create(name: "Mad Men", day_of_week: "Sunday", hour_of_day: 22, network: amc) | ||
Show.create(name: "Community", day_of_week: "Thursday", hour_of_day: 20, network: nbc) | ||
Show.create(name: "Top Chef", day_of_week: "Wednesday", hour_of_day: 19, network: bravo) | ||
Show.create(name: "Walking Dead", day_of_week: "Sunday", hour_of_day: 20, network: amc) | ||
|
||
Review.create(movie: "Pulp Fiction", | ||
rating: 5, | ||
reviewer: "Anthony Lane", | ||
synopsis: "The talk is dirty and funny, the violence always waiting just around the corner.") | ||
Review.create(movie: "Raiders of the Lost Ark", | ||
rating: 5, | ||
reviewer: "Gene Siskel", | ||
synopsis: "Yes, it's as entertaining as you have heard. Maybe more so. Raiders of the Lost Ark is, in fact, about as entertaining as a commercial movie can be.") | ||
Review.create(movie: "Amadeus", | ||
rating: 5, | ||
reviewer: "Gene Siskel", | ||
synopsis: "The subject of artistic creation is typically handled badly in the movies.... [Amadeus] treats the subject of creativity in a fresh way.") | ||
Review.create(movie: "American Hustle", | ||
rating: 5, | ||
reviewer: "Joe Neumaier", | ||
synopsis: "It turns out that comb-overs, cleavage, cocaine and kookiness are an unbeatable combo.") | ||
Review.create(movie: "The Big Lebowski", | ||
rating: 5, | ||
reviewer: "Rick Groen", | ||
synopsis: "A typical Coen brothers film is like no film you've ever seen.") |
This file contains 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,5 @@ | ||
class Review < ActiveRecord::Base | ||
def to_s | ||
"#{movie}, Reviewed by: #{reviewer}, Rating: #{rating}, Review: #{synopsis}" | ||
end | ||
end |
This file contains 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 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 |
---|---|---|
|
@@ -5,11 +5,22 @@ | |
Dir.glob('./models/*').each { |r| require r} | ||
require "./db/seed" | ||
|
||
puts "There are #{Show.count} in the database" | ||
i=0 | ||
|
||
Network.all.each do |network| | ||
puts "Shows airing on #{network}" | ||
network.shows.each do |show| | ||
puts show | ||
end | ||
puts "***********************" | ||
puts "* Welcome to WATCHMAN *" | ||
puts "***********************" | ||
puts "There are #{Review.count} reviews in the database:" | ||
puts "" | ||
Review.all.each do |review| | ||
i+=1 | ||
puts "#{review.movie}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should just do puts review.movie |
||
end | ||
puts "What movie review would you like to see?" | ||
print "> " | ||
|
||
movie_selection = gets.chomp.downcase | ||
|
||
my_selection = Review.all.select { |review| review.movie.downcase == movie_selection } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is database backed, we can use the DB to query now. So, you could do: my_selection = Review.where(movie: movie_selection) |
||
puts "Oops... we don't have a review for #{movie_selection} yet." if my_selection.empty? | ||
my_selection.each { |review| puts review } |
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.
Dont think you need to keep this, right?