maplesyrup / maple

This is the web portion of our app
4 stars 4 forks source link

Oldest posts appear first #437

Closed cvuong closed 11 years ago

cvuong commented 11 years ago

We should rework the algorithm so newer photos are worth more than older photos.

CalvinFernandez commented 11 years ago

:+1: We've gotten about 20 posts so far from new users. We need a filter mechanism urgently to make sure that quality content gets filtered to the top.

cvuong commented 11 years ago

The algorithm works when you are on the company page, but it doesn't work for the front page.

elihart commented 11 years ago

Turns out it doesn't quite work on the company page either. On zach's computer the posts were sorted from lowest vote count to highest... pretty much the worst way

benrudolph commented 11 years ago

I'm pretty sure this is an issue of elastic search records not being updated

On Thu, Jun 6, 2013 at 5:55 PM, Eli Hart notifications@github.com wrote:

Turns out it doesn't quite work on the company page either. On zach's computer the posts were sorted from lowest count to highest... pretty much the worst way

— Reply to this email directly or view it on GitHubhttps://github.com/maplesyrup/maple/issues/437#issuecomment-19083518 .

Ben Rudolph http://www.benrudolph.com | Stanford University B.S. Candidate 2013 | Computer Science

benrudolph commented 11 years ago

though i thought that was fixed

CalvinFernandez commented 11 years ago

@elihart, @cvuong. Company page just sends a fetch to posts with a specific company id as a parameter

Edit: No reason it should work

CalvinFernandez commented 11 years ago

Alright, I think I know what's going on. If you look at app/view/application/home.html.erb and scroll to the bottom you'll see the following line: posts: <%= Post.public_models(@posts, { :user => current_user }).html_safe %> We do this to bootstrap data to make page load faster. BUT sorting algorithm only gets called if you call Post.paged_posts. Otherwise it just dumps all the posts without calling sort. Fix that line and you'll fix your problem.

Additionally, the reason the posts are occasionally sorted on the company page and occasionally not sorted on the company page is because if we call MulticolumnView with the parameter bootstrapped=true then the front end will just grab all existing posts for that company without sending a request to posts/index?company=id. If you reload the page, I imagine MulticolumnView won't be bootstrapped anymore so it will send a fetch to posts/index?company=id which will in turn call paged posts, returning the correctly sorted data.

tl;dr: Change bootstrap in home.html.erb to paged_posts instead of public_models and you've fixed your problem.

benrudolph commented 11 years ago

code>@posts</code is populated by paged_posts: https://github.com/benrudolph/maple/blob/master/app/controllers/application_controller.rb#L6

public_models should just go through the array of posts and turn them into json without messing with the order

CalvinFernandez commented 11 years ago

sigh i think you're right. The search continues

CalvinFernandez commented 11 years ago

Is it a problem that we don't pass in options[:page] = 1 when bootstrapping. does search default to one regardless?

benrudolph commented 11 years ago

it defaults to 1

On Thu, Jun 6, 2013 at 6:29 PM, Calvin Fernandez notifications@github.comwrote:

Is it a problem that we don't pass in options[:page] = 1 when bootstrapping. does search default to one regardless?

— Reply to this email directly or view it on GitHubhttps://github.com/maplesyrup/maple/issues/437#issuecomment-19084327 .

CalvinFernandez commented 11 years ago

Donezo good work ben #442