fixed post stream to ascend by time
This commit is contained in:
parent
c63eac0fd9
commit
da9f33aa72
6 changed files with 25 additions and 17 deletions
|
|
@ -2,13 +2,6 @@ class DashboardController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@posts = Post.all
|
@posts = Post.recent_ordered_posts
|
||||||
|
|
||||||
@bookmarks = Bookmark.all
|
|
||||||
@status_messages = StatusMessage.all
|
|
||||||
@blogs = Blog.all
|
|
||||||
#@status_messages = @posts.select{ |x| x._type == "StatusMessage"}
|
|
||||||
#@blogs = @posts.select{ |x| x._type == "Blog"}
|
|
||||||
#@bookmarks = @posts.select{ |x| x._type == "Bookmarks"}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,24 @@ class Post
|
||||||
field :source
|
field :source
|
||||||
field :snippet
|
field :snippet
|
||||||
|
|
||||||
|
|
||||||
before_create :set_defaults
|
before_create :set_defaults
|
||||||
#after_update :notify_friends
|
#after_update :notify_friends
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@models = ["StatusMessage", "Bookmark", "Blog"]
|
||||||
|
|
||||||
|
def self.recent_ordered_posts
|
||||||
|
# Need to explicitly name each inherited model for dev environment
|
||||||
|
query = if Rails.env == "development"
|
||||||
|
Post.criteria.all(:_type => @@models)
|
||||||
|
else
|
||||||
|
Post.criteria.all
|
||||||
|
end
|
||||||
|
query.order_by( [:created_at, :desc] )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def set_defaults
|
def set_defaults
|
||||||
|
|
@ -33,7 +47,5 @@ class Post
|
||||||
#xml = self.to_xml_to_s
|
#xml = self.to_xml_to_s
|
||||||
#friends.each{|friend| ping friend :with => xml }
|
#friends.each{|friend| ping friend :with => xml }
|
||||||
#end
|
#end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
- title "Dashboard"
|
- title "Dashboard"
|
||||||
|
|
||||||
|
|
||||||
%ul#stream
|
%ul#stream
|
||||||
- for post in @posts
|
- for post in @posts
|
||||||
%li
|
%li
|
||||||
= render "shared/post", :post =>post
|
= render "shared/post", :post =>post
|
||||||
|
/= post.inspect
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Diaspora::Application.configure do
|
||||||
# test suite. You never need to work with it otherwise. Remember that
|
# test suite. You never need to work with it otherwise. Remember that
|
||||||
# your test database is "scratch space" for the test suite and is wiped
|
# your test database is "scratch space" for the test suite and is wiped
|
||||||
# and recreated between test runs. Don't rely on the data there!
|
# and recreated between test runs. Don't rely on the data there!
|
||||||
config.cache_classes = false
|
config.cache_classes = true
|
||||||
|
|
||||||
# Log error messages when you accidentally call methods on nil.
|
# Log error messages when you accidentally call methods on nil.
|
||||||
config.whiny_nils = true
|
config.whiny_nils = true
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ test:
|
||||||
# set these environment variables on your prod server
|
# set these environment variables on your prod server
|
||||||
production:
|
production:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
host: <%= ENV['MONGOID_HOST'] %>
|
#host: <%= ENV['MONGOID_HOST'] %>
|
||||||
port: <%= ENV['MONGOID_PORT'] %>
|
#port: <%= ENV['MONGOID_PORT'] %>
|
||||||
username: <%= ENV['MONGOID_USERNAME'] %>
|
#username: <%= ENV['MONGOID_USERNAME'] %>
|
||||||
password: <%= ENV['MONGOID_PASSWORD'] %>
|
#password: <%= ENV['MONGOID_PASSWORD'] %>
|
||||||
database: <%= ENV['MONGOID_DATABASE'] %>
|
#database: <%= ENV['MONGOID_DATABASE'] %>
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ Rspec.configure do |config|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
Mongoid.master.collections.select { |c| c.name != 'system.indexes' }.each(&:drop)
|
Mongoid.master.collections.select { |c| c.name != 'system.indexes' }.each(&:drop)
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue