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

Feat/dashboard viewing parties real #35

Merged
merged 9 commits into from
Dec 2, 2023
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ GEM
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-21
arm64-darwin-23

DEPENDENCIES
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ def index

def show
@user = User.find(params[:id])
@movie_info = @user.my_movies
if @movie_info != []
@image = @movie_info.first.image_url
else
end
end

def new
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/viewing_parties_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def create
party_duration: params[:party_duration],
start_time: params[:start_time],
movie_title: params[:movie_title],
movie_id: params[:movie_id]
movie_id: params[:movie_id],
host_id: @user.id
}

@viewing_party = ViewingParty.create!(viewing_party_params)
Expand Down
11 changes: 10 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# frozen_string_literal: true

class User < ApplicationRecord
has_many :viewing_parties
has_many :user_viewing_parties
has_many :viewing_parties, through: :user_viewing_parties

validates :name, presence: true
validates :email, presence: true, uniqueness: true

def my_movies
movies = []
viewing_parties.uniq.each do |party|
movies << MovieFacade.movie_details(party.movie_id)
movies << MovieFacade.cast(party.movie_id)
movies << MovieFacade.reviews(party.movie_id)
end
movies
end
end
4 changes: 3 additions & 1 deletion app/poros/movie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class Movie
:overview,
:cast,
:vote_count,
:review_info
:review_info,
:image_url

def initialize(attributes)
@movie_id = attributes[:id]
Expand All @@ -17,6 +18,7 @@ def initialize(attributes)
@genre = attributes[:genres]
@overview = attributes[:overview]
@vote_count = attributes[:vote_count]
@image_url = attributes[:poster_path]
end

def convert_runtime_to_hours_and_minutes
Expand Down
1 change: 1 addition & 0 deletions app/views/movies/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<ol><%= actor.name %> plays the character of "<%=actor.character%>"</ol>
<%end%>
<p><u>Vote Count</u>: <%=@movie_info.vote_count%></p>
<h3><u>Reviews</u></h3>
<%@reviews.each do |review|%></p>
<ol>
<p><u>Review Author</u>: <%= review.author %></p>
Expand Down
41 changes: 39 additions & 2 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,44 @@

<section id = "viewing-parties">
<h3>Parties I'm Hosting</h3>

<% @user.viewing_parties.each do |party| %>
<ol>
<% if party.host_id.to_i == @user.id %>
<%# <%= image_tag "https://image.tmdb.org/t/p/w92#{@image}" %><br>
<img src="https://tmdb.com/<%= @image %>"><br>
<u>Title:</u> <%= party.movie_title %><br>
<u>Date and Time:</u> <%= party.start_time %><br>
<% party.user_viewing_parties.each do |uvp| %>
<% if uvp.user_id == @user.id %>
<u>Users Attending:</u>
<% party.users.uniq.each do |user| %>
<%= user.name %>,
<% end %>
<% end %>
<% end %>
<% end %>
</ol>
<% end %>

<h3>Parties I'm Invited To</h3>

<% @user.viewing_parties.uniq.each do |party| %>
<ol>
<% if party.host_id.to_i != @user.id %>
<u>Title:</u> <%= party.movie_title %><br>
<u>Date and Time:</u> <%= party.start_time %><br>
<% party.user_viewing_parties.each do |uvp| %>
<% if uvp.user_id == @user.id %>
<u>Users Attending:</u>
<% party.users.each do |user| %>
<% if user.id == uvp.user_id %>
<strong><%= user.name %>,</strong>
<% else %>
<%= user.name %>,
<%end%>
<% end %>
<% end %>
<% end %>
<% end %>
</ol>
<% end %>
</section>
2 changes: 1 addition & 1 deletion config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lpnNiUJsWjK503WygUtt48WyX/eLVVgYZM/51BlddBW+QUajmOH2HFTvBuSMMwlPeFhuLJNk+ofaYuNM6xaG8M5HdW6C5Cb6HbPlLUwQeycjnO8ihcQPCC92ERpOJhQ8FDe6f/tXRWLza3+Xx/u9w90A6IpxOPqetjs4TLuCoEcgDXBx/NgSX5WC9JahKkNjZUlkpYk1XlDZRgGBxj5/drbUM0tPSTjEUYx+vgbvE5RYHSGCdcyxyuLYfpZp1U7ZuEVokgI3y8ORg7Hedh6pphW6JaqDMuJnRXOW/uRyYv9iwTBPIR6ZtzBxLqNEt/ZfS/Jbu//tLJVbNmJct4y1I6HFciwkLp8evC812rZUTsAgEW73rN4brww/u+Ufg3eD1OvgF1pabp4X25aN4iQl/eN6DHGXidcGWq9bReEXwemb09hMJnMvup1N9wBW2chf0CtaNdejsOCNGFuj2wGmB1Jc--3rYQu+j+pgHcwd2f--RnvvVt2iE1o2J6VJTL6WZQ==
gh/RPdJscelc3Mk8joueTTDzwBT5f45CSBn8PS5L3HgNDo6eFBe2w4qiktmhgKe4hpTQ3f1iIDbkvAqi4bdALVYSVgmbpHPstfvEosEkwCgVwoqvoWTgBT5EwNdxsBn/5/KKWi7ZjSL1mkfC94uPVFgm5kNlxTYNKfMVMmnyMu73wEXo3I8CEG4UhI2agB2+afZvwDYNu43tlfcsX52qDnj97+ZYlNKM2dJrYI17HscXiyq7bRrLI/Epal9uo6iaF579GVWQrHyLxCIJzQLrGz60VkUCsAKt2AMFVLo2N7DpNUGHGDpbPxSxMjLLRwd9dVLndzKzfLBCEWF3DlV0kABm4llAtGmiUhky0rF89+M1EJ9vOvMC7MHWTItq920J0Zas2y1IqtONnyS+iNX0IluhaYqsxsNQQZpuUK3dJu/M0wW0+RbPYpU11TMbbWVHbVxhhGBzfa/hhVWwpHj8+0v+tA==--2GjIhi6QH65PDJzB--06G7KEpGu+9ux0YA0YSbEg==
1 change: 1 addition & 0 deletions db/migrate/20231128002343_create_viewing_parties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def change
t.datetime :start_time
t.string :movie_title
t.string :movie_id
t.string :host_id

t.timestamps
end
Expand Down
49 changes: 25 additions & 24 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)

User.create!(name: 'Joseph Lee', email: 'jlee230@turing.edu')
User.create!(name: 'Joseph Lee', email: 'joseph@turing.edu')
User.create!(name: 'Kam', email: 'kam@turing.edu')
User.create!(name: 'Jamison', email: 'jamison@turing.edu')
User.create!(name: 'Chris', email: 'chris@turing.edu')
User.create!(name: 'Eric', email: 'eric@turing.edu')
2 changes: 1 addition & 1 deletion spec/facades/movie_facade_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

expect(page.status_code).to eq(200)
expect(page).to have_link('The Godfather')
expect(page).to have_content('8.708')
expect(page).to have_content('8.7')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/features/movies/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
expect(page).to have_content('The Godfather')
expect(page).to have_content('8.7')
expect(page).to have_content('The Shawshank Redemption')
expect(page).to have_content('8.705')
expect(page).to have_content('8.7')
expect(page).to have_content('The Godfather Part II')
expect(page).to have_content('8.5')
expect(page).to have_button('Discover')
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions spec/fixtures/vcr_cassettes/Pulp_Fiction.yml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions spec/fixtures/vcr_cassettes/cast.yml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions spec/fixtures/vcr_cassettes/movie_details.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions spec/fixtures/vcr_cassettes/reviews.yml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions spec/fixtures/vcr_cassettes/search_for_a_movie.yml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions spec/fixtures/vcr_cassettes/search_movies.yml

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions spec/fixtures/vcr_cassettes/top_rated_movies.yml

Large diffs are not rendered by default.