Skip to content

lindsay - edges - mediaranker#41

Open
elle-terch wants to merge 53 commits intoAda-C10:masterfrom
elle-terch:master
Open

lindsay - edges - mediaranker#41
elle-terch wants to merge 53 commits intoAda-C10:masterfrom
elle-terch:master

Conversation

@elle-terch
Copy link

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. In Work, I created a class method to tally total votes by work and then rank it from most votes to least. I used a query to take the votes table, join it with the works table and then group it by work.id. From there I used order to sort it from most votes to least (and had to troubleshoot some weird SQL stuff).
Describe how you approached testing that model method. What edge cases did you come up with? I wrote the methods first. Once I had them working locally, I went through each method and created tests for each of them. I did not come up with edge cases.
What are session and flash? What is the difference between them? Session and flash are special rails hashes. Flash displays a message to a user whereas session assigns a session id each time a user logs in (it persists until the user logs out).
Describe a controller filter you wrote. I didn't get around to writing controller filters.
What was one thing that you gained more clarity on through this assignment? In general, I gained more understanding of how all of the rails pieces fit together.
What is the Heroku URL of your deployed application? https://terch-mediaranker.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort? Maybe some more guidance on how much testing is expected for models. I did appreciate the open-ended nature of the project because it forced me to figure out what things to prioritize.

@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) some extra routes
Views are well-organized (DRY, use of semantic HTML, use of partials) semantic HTML is good, but views are not DRY - make sure to review partials
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, missing some edge cases
Wave 1 - Media
Splash page shows the three media categories yes
Basic CRUD operations on media are present and functional Can't delete a work with votes!
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 no
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 nope - make sure to get some practice with this on API muncher if you didn't on bEtsy
Look and feel is similar to the original workflow is similar
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 or your test coverage could be expanded, which I've tried to outline below, but in general I am quite happy with this submission. Keep up the hard work!

@top_movies = Work.top_ten("movie")
@top_albums = Work.top_ten("album")

@top_media = Work.top_media

Choose a reason for hiding this comment

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

Your custom model methods make this controller action very clean - good work!

def media_votes
combined_works = []

self.votes.each do |vote|

Choose a reason for hiding this comment

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

Why not use a has_many :through relationship for this?

class Vote < ApplicationRecord
belongs_to :user
belongs_to :work

Choose a reason for hiding this comment

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

If you wanted to make it so that each user can only vote for a given work once, you could do it with a validation here.

def self.top_ten(category)
top_ten = self.ranked_media(category)
top_ten.first(10)
end

Choose a reason for hiding this comment

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

I love the way the methods in this model build on each other little by little - this is a great example of functional decomposition.

<section class = "media-table">
<h4>Books</h4>
<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?

<h2>Edit this Work</h2>


<%= form_with model: @work do |f| %>

Choose a reason for hiding this comment

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

You have the same form code here and in new.html.erb. You should be using a partial to DRY this up.

end

resources :users

Choose a reason for hiding this comment

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

Do you need all 7 RESTful routes for user?


50.times do
book = Work.new(title: "Title#{x}", category: "Book")
book.save

Choose a reason for hiding this comment

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

I like this idea - test it by making a bunch of books in a loop. Good work!

describe 'top_ten' do

it 'returns only 10 entries of each category' do

Choose a reason for hiding this comment

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

I would also be interested in the following cases:

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

describe 'top_media' do

it 'has the most votes out of all media' do

Choose a reason for hiding this comment

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

I would also be interested in:

  • 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