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

Katricia - Edges - MediaRanker #34

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

Conversation

krsmith7
Copy link

@krsmith7 krsmith7 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 method to sort the works of media so that they would show in the spotlight page in order of number of votes.
Describe how you approached testing that model method. What edge cases did you come up with?
What are session and flash? What is the difference between them? Session stores the user information in a hash with user_id. It should persist until they log off. Flash deals with alert messages to the user.
Describe a controller filter you wrote. I wrote a controller filter to before controller actions check to see if there is a logged in user.
What was one thing that you gained more clarity on through this assignment? Connection between models with entity relationships.
What is the Heroku URL of your deployed application? https://media-ranker-site.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort?

@droberts-sea
Copy link

Media Ranker

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes (looks like you missed a question!)
General
Rails fundamentals (RESTful routing, use of named paths) yes
Views are well-organized (DRY, use of semantic HTML, use of partials) yes
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 The methods that are tested are tested well - good work. Looks like you ran out of time at the end, but it's at least worth reviewing the model tests on MediaRanker-Revisited to see how we approached it.
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 work overall! You nailed the functionality of this site, you've done a good job of putting business logic in the model, and you've made a strong start on test coverage. It is clear to me that the learning goals for this assignment were met. I've left a number of comments inline below, but in general I am happy with what I see here. Keep up the hard work!

belongs_to :work

validates :user_id, presence: true
validates :work_id, presence: true, uniqueness: { scope: :user_id }

Choose a reason for hiding this comment

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

Good work getting this scope figured out!

def self.get_top_work
works = Work.all.to_a
highest= works.sort_by{|item| item.votes_count}.reverse
return highest.first

Choose a reason for hiding this comment

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

Instead of reversing and taking the first, you could take the last.

def self.get_top_list(category)
category_works = Work.get_category_media(category).to_a
# sorted = category_works.sort_by{|item| item.votes_count}.reverse
# return sorted[0..9]

Choose a reason for hiding this comment

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

Good job reusing existing functionality here!

redirect_to work_path(id: @vote.work.id)
else
flash[:notice] = "A problem occurred: Could not upvote: user has already voted for this work"
redirect_back fallback_location: :work_path

Choose a reason for hiding this comment

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

This error message assumes that the only way the vote could fail to save is if it was a duplicate. The way your application currently works that is true, but if you were to continue to work on this you might introduce another validation, which would then require this code to change. A better approach would be to read errors.messages (and set it in the validation if needed).

If you want to think of it from a POODR point of view, we could say that this code knows too much about how your model works.

<strong><%column.capitalize %> </strong><%= message %>
<% end %>
<% end %>
<% end %>

Choose a reason for hiding this comment

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

Watch your indentation here. I want to recognize that the Atom auto-indenter doesn't work well for ERB, but that doesn't mean we don't have to make our code easy to follow.

If you needed to isolate this bit so it's not affected by the auto-indenter, you might use a view partial.

<section>
<% Work::WORK_CATEGORIES.each do |category| %>
<h4 class="black-hdg"><%= category.capitalize%>s</h4>
<table class="table">

Choose a reason for hiding this comment

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

Great work DRYing up this view code!

root 'top_works#index'

resources :users

Choose a reason for hiding this comment

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

Do you really need all 7 RESTful routes for users? Remember to be careful about using resources, and only generate the routes you need.


it "is valid if work is not unique" do
vote2 = votes(:two)
vote4 = votes(:four)

Choose a reason for hiding this comment

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

Good job on these test cases for the vote validation. There's a lot of interesting cases here, and I think you've found them all.

it "sorts list in order of votes" do
@works.first.title.must_equal works(:memento).title
end
end

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 memento fixture work_with_the_most_votes, since that's what's interesting about it.

# add more fixtures so can test with over ten category works?

# describe get_top_work
# must return work with most votes

Choose a reason for hiding this comment

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

I would be interested in what the rest of these tests look like.

One approach might be to create works and votes in a loop.

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