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

Sigrid Benezra - Edges - MediaRanker #30

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

Conversation

sdbenezra
Copy link

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. I wrote a method on the work model to test sorting works by category.
Describe how you approached testing that model method. What edge cases did you come up with? I used the work.yaml file and a fixture file for votes on two of the works. I tested for the most votes and the least, but couldn't think of another edge case.
What are session and flash? What is the difference between them? Flash will store data for one response cycle, but session will store data until a user closes the session.
Describe a controller filter you wrote. I wrote one controller filter that saved the logged in user to an instance variable.
What was one thing that you gained more clarity on through this assignment? Active record associations and how they allow you to access data and methods from one object through another.
What is the Heroku URL of your deployed application? https://siggys-mediaranker.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort?

…o db. Change works index page to list all works as list.
… Add link to edit page from works show page.
…_form.html.erb for better display. Make title on works index page a link to the work show page.
…op vote getter and list works by category and vote total.
…ntroller method to flash message for missing user id.
@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 unused routes and controller actions were built
Views are well-organized (DRY, use of semantic HTML, use of partials) some repetition, but mostly OK
Errors are reported to the user mostly - validation failures are not reported
Business logic lives in the models yes - good work
Models are thoroughly tested, including relations, validations and any custom logic could be much better
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 - bug: trying to vote when not logged in produces an error
The ID of the current user is stored in the session mostly - see inline
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 - great work
Overall Good work overall. You've done a great job replicating the functionality of the demo site, and it's clear to me that most of the learning goals for this assignment were met. The one place where I see room for improvement is testing - make sure to review my inline comments, and practice this intentionally on future projects. I would be happy to sit down and review your test coverage before a project is due if that would help. Other than that I'm quite happy with this submission - keep up the hard work!

else
user = User.create(name: name)
redirect_to root_path
flash[:success] = "#{user.name} is successfully logged in"

Choose a reason for hiding this comment

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

When you create a new user you're not saving their ID in the session. That means that a new user has to enter their name twice to log in: once to create the record, and once to set their user ID in the session.

def update
@user = User.find(params[:id])
if @user.update(user_params)
redirect_to user_path(@user)

Choose a reason for hiding this comment

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

You've implemented all 7 RESTful controller actions for User, but I think you only need index and show for this site.


def new
user = @logged_in_user
work = Work.find_by(id: params[:work_id])

Choose a reason for hiding this comment

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

Again, you've implemented the index and new actions for the VotesController, but they're not used by your site, and you don't have view templates for them.

belongs_to :user

validates :user_id, presence: true, uniqueness: { scope: :work_id,
message: "can only vote for a 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!


def self.top_vote_getter_votes
return Work.top_vote_getter.votes.size
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 file build on each other, each providing a small bit of functionality. This is an excellent example of functional decomposition.

<h2><span><strong>Media Spotlight: </strong></span><span class="list-titles"><%= link_to Work.top_vote_getter.title, work_path(Work.top_vote_getter.id) %></span><span class="list-titles"> by <%= Work.top_vote_getter.creator %> </span></h2>
<p>
<%= Work.top_vote_getter_votes %> votes - <%= Work.top_vote_getter.description %>
</p>

Choose a reason for hiding this comment

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

Rather than having the views call model methods directly, these method should be invoked in the controller and stored in instance variables. See MediaRanker Revisited for an example of this.

Top Albums
</h2>
<ul class="list-group">
<% Work.top_works_by_category('album', 10).each do |work| %>

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?

<% end %>
</section>

<body>

Choose a reason for hiding this comment

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

All HTML that renders on the page (including the <header> and flash <section>) should be inside the <body> tags.


# describe Vote do
# let(:vote) { Vote.new }
#

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 'list_works_by_category' do

it 'correctly filters the list for a category' do
book_list = Work.list_works_by_category('book')

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 finding the media spotlight, 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