Skip to content

Code review#26

Open
philsof wants to merge 86 commits intocode-reviewfrom
master
Open

Code review#26
philsof wants to merge 86 commits intocode-reviewfrom
master

Conversation

@philsof
Copy link
Copy Markdown

@philsof philsof commented Mar 31, 2017

DO NOT MERGE THIS PULL REQUEST!

Jordany Rosas & Michael Benson & Paul Gallagher and others added 30 commits March 29, 2017 09:59
Implemented restful routes for Movie controller
Added a basic showpage, moving cause of sun
Basic html views for movies
Copy link
Copy Markdown
Author

@philsof philsof left a comment

Choose a reason for hiding this comment

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

@IuliiaKot @mabenson00 @paulizleet @jordanyryan See inline notes for tips and comments

@@ -0,0 +1,25 @@
class BacklogsController < ApplicationController
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

What is a backlog? Is this your watchlist? Please use names that describe what is being represented.

class CreateReviews < ActiveRecord::Migration[5.0]
def change
create_table :reviews do |t|
t.string :movie_id
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Best practice is to index all foreign key fields. t.references does this automatically, but here you would need to be explicit:

t.string :movie_id, index: true

Note: this goes for all movie_id fields in all of your tables

def change
create_table :comments do |t|
t.string :movie_id
t.references :user, foreign_key: true
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

How could you have implemented comments on other comments? A la Hacker News conversations?

def activity_feed
feed = []
feed << self.favorites
feed << self.backlogs
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

How could you have also tracked activity that removes records from the database, e.g. when a movie is unfavorited and/or removed from a watchlist?

feed << self.backlogs
feed << self.comments
feed << self.reviews
feed.flatten
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

FYI Flattening an array is expensive. What if you had a log table that recorded every user activity? That would come in handy when querying (see next note).

module ReviewsHelper

def reviews_find_movie

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

???

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

oh i see


<%= javascript_include_tag 'application' %>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/css/materialize.min.css">
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Let's utilize the asset pipeline to bring in all of the CSS and JS assets. More info on why this is a best practice, and how to do so, here

</div>
</footer>
<script type="text/javascript" charset="utf-8">
$(window).load(function() {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Let's move this into the JS assets



<%= form_for :movies url: movie_path, method: :patch do |f| %>
<% if @article.errors.any? %>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

👍 error messaging, good UX

<%=link_to movie[:Title], "/movies/#{movie[:imdbID]}", class: "homepage-link" %>
</div>
<div class="overlay-stars">
<%= Review.for_movie(movie[:imdbID])[-1].stars %>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Let's not reach into an array in the view. Have the model deliver to the view exactly what it needs.

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.

4 participants