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

Katrina - Edges - Media Ranker #31

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

Conversation

kaganon
Copy link

@kaganon kaganon commented Oct 15, 2018

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. One custom model method in my program was for finding the top ten media for the welcome page. I used the active record query where method to find all the media of the same category. I used the sort_by enumerable to sort the works by count of votes, and then reversed the order since we want the highest votes first. Then, I returned only the first 10 works to get the top 10 works by votes for a category.
Describe how you approached testing that model method. What edge cases did you come up with? One of the tests I included was to make sure that it returns only the works of the same category that was passed in the parameters. If I looped through each work, I expected that all the work's category will be the same as the one passed in the parameter.
What are session and flash? What is the difference between them? Session and flash are both hash like objects, but are used in different ways. A session is utilized to keep track of user data when they log in, and the data can be stored indefinitely. Flash is used to send a one-time message from the controllers to the views, and used overall to denote a success or failure when submitting a form. They usually disappear after they are displayed once.
Describe a controller filter you wrote. I used the before_action find_work to find an instance of work by the id that matches the id provided in the params. This controller filter helped to DRY up the controller code where I used the same find_by method multiple times in my controller actions.
What was one thing that you gained more clarity on through this assignment? I think overall I learned a lot about keeping business logic in the models and how that keeps the application DRY and readable. I am also more comfortable with model testing and using fixtures data in the model testing. I'm also more aware of how much I take webpages for granted because this was a lot of work for a "simple" web app.
What is the Heroku URL of your deployed application? http://mediabuzz.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort? No, I think this project was really well organized. It was challenging, but I really enjoyed it! But I think it was a bit challenging having this project along with a Unit test due at the same time.

@droberts-sea
Copy link

Media Ranker

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes
General
Rails fundamentals (RESTful routing, use of named paths) mostly - some unneeded routes generated
Views are well-organized (DRY, use of semantic HTML, use of partials) mostly - see inline
Errors are reported to the user yes
Business logic lives in the models yes
Models are thoroughly tested, including relations, validations and any custom logic good start - see inline
Wave 1 - Media
Splash page shows the three media categories yes
Basic CRUD operations on media are present and functional yes
Wave 2 - Users and Votes
Users can log in and log out yes
The ID of the current user is stored in the session yes
A user cannot vote for the same media more than once yes
All media lists are ordered by vote count yes
Splash page contains a media spotlight yes
Wave 3 - Users and Votes
Media pages contain lists of voting users yes
Individual user pages and the user list are present yes
Optional - Styling
Bootstrap is used appropriately yes
Look and feel is similar to the original yes - good work
Overall Great job overall! Your implementation matches the demo site very closely, and I would say the learning goals for this assignment were definitely met. There are a few places where things could be cleaned up, which I've tried to outline below, but in general I am quite happy with this submission. Keep up the hard work!


validates :user_id, presence: true
validates :work_id, presence: true
validates_uniqueness_of :work_id, scope: :user_id

Choose a reason for hiding this comment

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

Nice work figuring out how to restrict voting via validations.

CATEGORIES = ["album", "book", "movie"]

validates :title, presence: true
validates :category, inclusion: { in: CATEGORIES }

Choose a reason for hiding this comment

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

I love that you stored the list of categories in a constant!

class WorksController < ApplicationController
before_action :find_work, only:[:show, :edit, :update, :upvote]
before_action :find_top_media, only:[:welcome]
before_action :find_all_works, only:[:index]

Choose a reason for hiding this comment

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

If a controller filter applies to only one action, then it doesn't DRY things up because that code wasn't repeated anyway. But, it does make the flow of the code harder to follow. I would probably keep this work in the action.


if @work.nil?
head :not_found
end

Choose a reason for hiding this comment

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

This code is repeated several times in this controller. Would it make sense to put this check inside the find_work controller filter?

<h4><strong>Books</strong></h4>

<table class="table ">
<thead>

Choose a reason for hiding this comment

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

You have the same code to show a list of works repeated 3 times. Could you use a view partial or a loop to DRY this up?


resources :users, only:[:index, :new, :show] do
resources :votes, except:[:edit, :destroy]
end

Choose a reason for hiding this comment

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

You include nested routes for votes under both works and users. However, I don't think that any of these routes are used by this application. You should remove them.


it 'is valid when a user_id is unique for votes for the same work' do
first_vote = votes(:vote_one)
second_vote = votes(:vote_three)

Choose a reason for hiding this comment

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

Nice work figuring out all the interesting test cases for the uniqueness validation here.

it 'returns the 10 works in descending order based on votes' do
works = Work.top_media('book')

expect( works.first ).must_equal works(:potter)

Choose a reason for hiding this comment

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

It is not obvious to me that this test is actually checking what it's name says. Is there something you could do to show the work of arranging this test? It could even be something like renaming the potter fixture work_with_the_most_votes, since that's what's interesting about it.

describe 'top_media' do

it 'returns only 10 works' do
works = Work.top_media('book')

Choose a reason for hiding this comment

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

There are a couple other interesting cases I would like you to consider here:

  • What if there are no works of that category?
  • What if there are less than 10 works?
  • What if there's a tie for last place, e.g. works 9, 10 and 11 all have 0 votes?

describe 'spotlight' do

it 'returns the work with the most amount of votes' do
most_votes = Work.spotlight

Choose a reason for hiding this comment

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

Similar to the top_media method above, you're missing some cases here.

  • What happens if there are no works?
  • What happens if there are works but no votes?
  • What happens if two works have the same number of votes?

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.

2 participants