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

Michelle - Edges - MediaRanker #35

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

Conversation

kangazoom
Copy link

@kangazoom kangazoom commented Oct 15, 2018

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. I wrote a series of methods to help me count votes (for users and works), organize them by category, sort them by votes, and choose either the top ten -- or the top overall across all categories.
Describe how you approached testing that model method. What edge cases did you come up with? For choosing the top ten, I created a bunch of new works through a loop since the fixture only had two from each category.
What are session and flash? What is the difference between them? They are both hash-like objects that persist through cookies (flash between requests and session until a user closes their browser).
Describe a controller filter you wrote. I wrote one for a logged in user, connecting sessions to Users.
What was one thing that you gained more clarity on through this assignment? How to use model methods and self.
What is the Heroku URL of your deployed application? https://michelle-ranks-media.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort? seeding for this one was unlike any other project; heroku wouldn't work properly unless the db was properly seeded. seeding is not part of the requirements though, so wasn't sure if it was actually needed (until i ran into heroku issues).

… and edited user view a little to see the user info
@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) yes
Views are well-organized (DRY, use of semantic HTML, use of partials) some repetition - 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 many edge cases are missing - 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 You've got a syntax error on the login page. Removing the extra comma makes this work perfectly.
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 some - would like to see alerts for flash messages
Look and feel is similar to the original workflow is the same
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.

The big place where I see room for improvement is with model testing, particularly coming up with edge cases for your custom methods, so be sure to practice this on bEtsy, and feel free to ask an instructor to review your test coverage before it's due.

You left a lot of questions inline, which I like. Make sure to review our code on MediaRanker Revisited, I think it addresses many of these.

In general I am quite happy with this submission. Keep up the hard work!


def count_votes
return self.votes.length
end

Choose a reason for hiding this comment

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

I like that you put this method in ApplicationRecord - good use of inheritance.

belongs_to :work
belongs_to :user

validates :user, presence: true, uniqueness: { scope: :work, message: "You may only vote on this work once."}

Choose a reason for hiding this comment

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

Good work getting this tricky uniqueness scope figured out!

validates :title, presence: true, uniqueness: {scope: :category, message: "This category already knows about that title." }
# TODO: validates :publication_year --> how to get year only??

# TODO: necessary???? validates_inclusion_of :category, :in => CATEGORIES

Choose a reason for hiding this comment

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

I would say the inclusion validation would be important. If we've built our views correctly then it shouldn't be possible for a user to send in an invalid category, but it would be a good safety check for yourself to make sure you've wired things up correctly. For example, if you misspelled "ablum" in the category dropdown menu, this would catch it.

def self.sort_works(work_category)
cat_works_array = categorize_works(work_category)
works_by_vote = cat_works_array.sort_by{|work| work.count_votes}.reverse
return works_by_vote

Choose a reason for hiding this comment

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

I love how the methods in this file build upon one another, each adding a small amount of functionality. This is an excellent example of functional decomposition.

class WelcomeController < ApplicationController

def index
@albums = Work.gen_top_ten_works('album')

Choose a reason for hiding this comment

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

I think that this action would probably fit in the works controller. It's not wrong here, but it is an extra file to pay attention to.

def show
if @work = Work.find_by(id: params[:id])
return @work
else

Choose a reason for hiding this comment

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

You repeat this code of finding the work and checking the result many times in this controller. This might be a good place to use a filter.

<h2 class="top-ten__header">
Top Movies
</h2>
<% @movies.each do |movie| %>

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?

describe Vote do
let(:vote) { votes(:user1_book1) }

it "must belong to a user" do

Choose a reason for hiding this comment

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

You should be testing the uniqueness constraint here! Specific test cases I'd want to see:

  • A user can have votes for two different works
  • A work can have votes from two different users
  • A user cannot vote for the same work twice


describe 'sort works' do

it 'sorts works by most to least votes' do

Choose a reason for hiding this comment

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

There's a lot of interesting test cases for your custom Work methods missing here. For top_work, I would wonder:

  • 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?

Similarly for your category and top ten methods, I would ask:

  • 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?

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