Skip to content

Commit

Permalink
Commented-on posts bubble up to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael committed Dec 1, 2010
1 parent 8d853a8 commit 6da4100
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/controllers/aspects_controller.rb
Expand Up @@ -9,7 +9,7 @@ class AspectsController < ApplicationController
respond_to :json, :only => :show

def index
@posts = current_user.visible_posts(:_type => "StatusMessage").paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
@posts = current_user.raw_visible_posts.find_all_by__type("StatusMessage", :order => 'updated_at desc').paginate :page => params[:page], :per_page => 15
@post_hashes = hashes_for_posts @posts
@aspect_hashes = hashes_for_aspects @aspects.all, @contacts
@aspect = :all
Expand Down Expand Up @@ -62,7 +62,7 @@ def show
@aspect_contacts = @aspect.contacts
@aspect_contacts_count = @aspect_contacts.count

@posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'created_at desc').paginate :page => params[:page], :per_page => 15
@posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'updated_at desc').paginate :page => params[:page], :per_page => 15
@post_hashes = hashes_for_posts @posts
@post_count = @posts.count

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/people_controller.rb
Expand Up @@ -11,7 +11,7 @@ class PeopleController < ApplicationController
def index
@aspect = :search

@people = Person.search(params[:q]).paginate :page => params[:page], :per_page => 25, :order => 'created_at DESC'
@people = Person.search(params[:q]).paginate :page => params[:page], :per_page => 25, :order => 'updated_at DESC'
@requests = Request.all(:to_id.in => @people.map{|p| p.id})

#only do it if it is an email address
Expand Down Expand Up @@ -39,7 +39,7 @@ def show
@aspects_with_person = @contact.aspects
end

@posts = current_user.visible_posts(:person_id => @person.id, :_type => "StatusMessage").paginate :page => params[:page], :order => 'created_at DESC'
@posts = current_user.visible_posts(:person_id => @person.id, :_type => "StatusMessage").paginate :page => params[:page], :order => 'updated_at DESC'
@post_hashes = hashes_for_posts @posts
respond_with @person, :locals => {:post_type => :all}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/photos_controller.rb
Expand Up @@ -21,7 +21,7 @@ def index
@aspects_with_person = @contact.aspects
end

@posts = current_user.raw_visible_posts.all(:_type => 'Photo', :person_id => @person.id, :order => 'created_at DESC').paginate :page => params[:page], :order => 'created_at DESC'
@posts = current_user.raw_visible_posts.all(:_type => 'Photo', :person_id => @person.id, :order => 'updated_at DESC').paginate :page => params[:page], :order => 'created_at DESC'

render 'people/show'

Expand Down
5 changes: 5 additions & 0 deletions app/models/comment.rb
Expand Up @@ -36,6 +36,11 @@ class Comment
validates_presence_of :text, :diaspora_handle, :post
validates_with HandleValidator

after_create do
#save the parent post to update updated_at timestamp
post.save
end

before_save do
get_youtube_title text
end
Expand Down
9 changes: 9 additions & 0 deletions spec/models/comment_spec.rb
Expand Up @@ -70,6 +70,15 @@
user2.comment "sup dog", :on => @status
@status.reload.comments.first.text.should == "sup dog"
end

it "updates updated_at of parent post on creation" do
hash = @status.to_mongo
hash[:updated_at] = (Time.now - 20).to_s
@status.collection.save(hash)
user2.comment "sup dog", :on => @status
@status.reload.updated_at.should == @status.comments.first.created_at
end

end

it 'should not send out comments when we have no people' do
Expand Down

0 comments on commit 6da4100

Please sign in to comment.