paginating participate stream
This commit is contained in:
parent
3991903b56
commit
354ed7ef05
3 changed files with 17 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ class Post < ActiveRecord::Base
|
|||
}, :as => :text
|
||||
t.add :public
|
||||
t.add :created_at
|
||||
t.add :interacted_at
|
||||
t.add :comments_count
|
||||
t.add :likes_count
|
||||
t.add :reshares_count
|
||||
|
|
|
|||
|
|
@ -6,7 +6,15 @@ app.models.Post = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
createdAt : function() {
|
||||
return new Date(this.get("created_at")) / 1000;
|
||||
return this.timeOf("created_at");
|
||||
},
|
||||
|
||||
interactedAt : function() {
|
||||
return this.timeOf("interacted_at");
|
||||
},
|
||||
|
||||
timeOf: function(field) {
|
||||
return new Date(this.get(field)) /1000;
|
||||
},
|
||||
|
||||
createReshareUrl : "/reshares",
|
||||
|
|
|
|||
|
|
@ -42,7 +42,13 @@ app.models.Stream = Backbone.Collection.extend({
|
|||
},
|
||||
|
||||
timeFilteredPath : function(){
|
||||
return this.basePath() + "?max_time=" + _.last(this.posts.models).createdAt();
|
||||
return this.basePath() + "?max_time=" + this.maxTime();
|
||||
},
|
||||
|
||||
maxTime: function(){
|
||||
var lastPost = _.last(this.posts.models);
|
||||
var isOnParticipateStream = this.basePath().match(/participate/);
|
||||
return (isOnParticipateStream == null) ? lastPost.createdAt() : lastPost.interactedAt();
|
||||
},
|
||||
|
||||
add : function(models){
|
||||
|
|
|
|||
Loading…
Reference in a new issue