+5
-6
lib/tasks/feeds.rake
+5
-6
lib/tasks/feeds.rake
···
178
178
end
179
179
180
180
def rebuild_feed(feed, days, append_only, dry = false)
181
-
posts = Post.order('time, id')
182
-
start = posts.where("time <= DATETIME('now', '-#{days} days')").last
183
-
stop = posts.last
184
-
first = posts.first
185
-
total = start ? (stop.id - start.id + 1) : (stop.id - first.id + 1)
186
-
187
181
if append_only
188
182
feed_posts = FeedPost.where(feed_id: feed.feed_id)
189
183
current_post_ids = Set.new(feed_posts.pluck('post_id'))
···
196
190
FeedPost.where(feed_id: feed.feed_id).delete_all
197
191
current_post_ids = []
198
192
end
193
+
194
+
puts "Counting posts..."
195
+
posts = Post.order('time, id')
196
+
start = posts.where("time <= DATETIME('now', '-#{days} days')").last
197
+
total = start ? Post.where("time > DATETIME('now', '-#{days} days')").count : Post.count
199
198
200
199
offset = 0
201
200
page = 100000