Skip to content

Tor S - Octos - MediaRanker#21

Open
torshimizu wants to merge 47 commits intoAda-C9:masterfrom
torshimizu:master
Open

Tor S - Octos - MediaRanker#21
torshimizu wants to merge 47 commits intoAda-C9:masterfrom
torshimizu:master

Conversation

@torshimizu
Copy link
Copy Markdown

Media Ranker

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a custom model method you wrote. I wrote a method to order a category of works by vote, I also wrote recommender methods for a user.
Describe how you approached testing that model method. What edge cases did you come up with? To test the ordering by vote, I created a few users and works in the yaml file, had the users vote for one work more than the other works. I manually ordered these created works in an array, and said that the result of calling my order method would be equal to the manually sorted array. To be honest, I did not test edge cases very well.
What are session and flash? What is the difference between them? Session and flash are hash like objects that are packaged with cookies and sent along the http cycle. Session lasts while one IP is logged in to one browser (while not on incognito mode). Flash lasts for one request cycle (or for the remainder of the request cycle - flash.now)
Describe a controller filter you wrote. I had a controller action to find a work. I also had one to find the user using session[:user_id], that would store the user in a variable that could be used by the view to show the user as logged in on all pages across the site.
What was one thing that you gained more clarity on through this assignment? TESTING - how to seed the test database, using the test console, writing ERB in yaml files.
What is the Heroku URL of your deployed application? https://ranktopus.herokuapp.com/
Do you have any recommendations on how we could improve this project for the next cohort? mention you can have ERB in yaml files, demonstrate how foundation would work. Go more in depth on unit testing - many people still didn't understand how testing worked (where to get the data, what to test, etc.)

…ion for user to only be able to vote once for a work, added tests for the validation
@droberts-sea
Copy link
Copy Markdown

Media Ranker

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes - good work
Comprehension questions yes
General
Rails fundamentals (RESTful routing, use of named paths) yes
Semantic HTML yes
Errors are reported to the user yes
Business logic lives in the models mostly - see inline
Models are thoroughly tested, including relations, validations and any custom logic
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
Individual user pages and the user list are present 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
Media pages contain lists of voting users yes
Wave 3 - Styling
Foundation is used appropriately yes
Look and feel is similar to the original yes
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, which I've tried to outline below, but in general I am quite happy with this submission.

Particular problems I ran into:

  • I had trouble running the site locally because your seed file doesn't create any categories. The idea of the seeds is to set up the database from scratch, so they shouldn't rely on something already being there. Once I added the categories in the Rails console everything worked fine.
  • As a result of this, I uncovered a couple bugs: none of your list pages work if the expected categories aren't there, the spotlight section of your top works page hits an error if there are no works, and the user show page breaks if a user hasn't voted for anything yet.

I'm super impressed by your work on the recommender system! That was not intended to be an easy optional. Excellent work.

If you want to keep tinkering with this, the next step is to think about performance. Every time you load a user you compare them to all the other users, which means complexity grows linearly with the number of users. How could you scale a system like this up to a million users, or 100 million? What trade-offs would you need to consider?

If you're interested in seeing another complex algorithm implemented in a Rails app, our internship-placer-app has an interesting bit of logic under lib/solver.rb to calculate an initial placement based on interview results. The file is well commented and might be an interesting read, if you're into linear algebra, but the structure of it and the accompanying tests are definitely worth checking out.

Comment thread app/models/user.rb
recommendations = User.get_recommendations(top_similar, new_user) # this should probably not be a class method but it is for now for testing

return recommendations.empty? ? "no recommendations at this time" : recommendations.uniq
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The condition in line 25 is display logic, and would probably fit better in the view.

def top
@top_albums = Work.order_by_vote(categorize('album')).first(10)
@top_books = Work.order_by_vote(categorize('book')).first(10)
@top_movies = Work.order_by_vote(categorize('movie')).first(10)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These lines might work well as a model method, something like top_ten(category).


<% if @albums %>
<%= render partial: 'display_work', locals: {category: 'Albums', model: @albums} %>
<% end %>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good use of a partial to keep this DRY.

Comment thread test/models/user_test.rb
it 'must calculate a jaccard index between a two users' do
result = User.calculate_jaccard(@tor, @roo)

result.must_equal 0.5
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm going to start by appreciating that you have test coverage here at all - it's easy to let it slip when you're working on a science project like this.

That being said, the test coverage here could probably stand to be more broad. What if one of the users doesn't have any votes? What if there is no intersect, or if the intersect is the union? Does it work with many works?

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