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

Naheed MediaRanker Edges #48

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

Naheed MediaRanker Edges #48

wants to merge 12 commits into from

Conversation

arangn
Copy link

@arangn arangn 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 works based on votes in my works model
Describe how you approached testing that model method. What edge cases did you come up with? I tested the method to make sure it sorted works based on votes, and also tested whether the works show up if there are none as an edge case
What are session and flash? What is the difference between them? Session is to record the current user, while flash is used to display a message to the user.
Describe a controller filter you wrote. I created a find work filter that finds a record based on the id
What was one thing that you gained more clarity on through this assignment? How everything talks to each other, how to do a rails project start to finish, how to copy paste code without feeling guilty
What is the Heroku URL of your deployed application? https://media-ranker-naheed.herokuapp.com
Do you have any recommendations on how we could improve this project for the next cohort? More time pls

@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 generated
Views are well-organized (DRY, use of semantic HTML, use of partials) great semantic HTML, some repetition of view code (see inline)
Errors are reported to the user some - this could be much more comprehensive
Business logic lives in the models yes - great work
Models are thoroughly tested, including relations, validations and any custom logic good start, but many edge cases missing - see inline
Wave 1 - Media
Splash page shows the three media categories yes
Basic CRUD operations on media are present and functional I was not able to create a new work, but the other operations worked fine
Wave 2 - Users and Votes
Users can log in and log out yes (but see inline)
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 no
Individual user pages and the user list are present some - list of votes on the user page isn't quite there
Optional - Styling
Bootstrap is used appropriately yes
Look and feel is similar to the original workflow is the same, styling less so
Overall

Good work overall. I was right on the border between yellow and green on this one. Some of the wave 3 functionality is incomplete, but in general this site functions well, and it is clear to me that the learning goals for this assignment were met, especially around working with complex business logic.

I don't have much insight into this, but probably the place where there's the most room for growth is in writing code quickly and efficiently. Part of this is just practice, but if you'd like to discuss tools for working on this I'd be happy to.

There is also some room for improvement around testing, but you're on the right track here. As you work on bEtsy, it might be worthwhile to seek out an instructor or TA to get feedback on test coverage before the deadline.

There are a few places where things could be cleaned up, which I've tried to outline below, but in general I am pretty happy with this submission. Keep up the hard work!

else
@user = User.new(username: name)
@user.save
redirect_to root_path

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.

if save_success
redirect_to works_path
else
render :new

Choose a reason for hiding this comment

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

It would be good to put a message in the flash in both these cases, either "successfully created work" or "could not create work".

def self.voted_works(user_id)
works = User.where(id: user_id)
return works
end

Choose a reason for hiding this comment

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

This method returns a list of (one) user, not a list of works. Why not use a has_many :through relationship here?

belongs_to :user
belongs_to :work
validates :work, uniqueness: { scope: :user }
validates :user, uniqueness: { scope: :work }

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! However, I think you only need one or the other of these lines, not both.

def self.list_top_ten(category)
works = Work.sort_works(category)
return works[0..9]
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 these model methods build on each other, each adding a small bit of functionality. This is a great example of functional decomposition.

<h2 class="top-ten__header">
Top Movies
</h2>
<ul class="list-group top-ten__list">

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?

post '/sessions/logout', to: 'sessions#logout', as: 'logout'

resources :users

Choose a reason for hiding this comment

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

I don't think you need all 7 RESTful routes for users. This site should only use index and show.

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

it "must be valid" 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 based on votes" do
sorted = Work.sort_works("album")
first = sorted.first.votes.count

Choose a reason for hiding this comment

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

This is a good start to testing for your custom model methods, but there's some interesting edge cases you haven't covered.

For find_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 sort_works 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