+9
-8
lib/tasks/feeds.rake
+9
-8
lib/tasks/feeds.rake
···
119
119
method = ENV['UNSAFE'] ? :tap : :transaction
120
120
dry = !!ENV['DRY_RUN']
121
121
122
+
if ENV['ONLY_EXISTING'] && ENV['APPEND_ONLY']
123
+
raise "APPEND_ONLY cannot be used together with ONLY_EXISTING"
124
+
end
125
+
122
126
ActiveRecord::Base.send(method) do
123
127
if ENV['ONLY_EXISTING']
124
128
rescan_feed_items(feed, dry)
···
211
215
$stderr.flush
212
216
213
217
if !current_post_ids.include?(post.id) && feed.post_matches?(post)
214
-
if dry
215
-
matched_posts << post
216
-
else
217
-
FeedPost.create!(feed_id: feed.feed_id, post: post, time: post.time)
218
-
end
218
+
matched_posts << post
219
+
FeedPost.create!(feed_id: feed.feed_id, post: post, time: post.time) unless dry
219
220
end
220
221
end
221
222
···
225
226
226
227
$stderr.puts "Processing posts... Done." + " " * 30
227
228
228
-
if dry
229
+
if dry || ENV['VERBOSE']
229
230
if append_only
230
-
puts "Added posts:"
231
+
puts (dry ? "Posts to add: " : "Added posts: ") + matched_posts.length.to_s
231
232
puts "=============================="
232
233
puts
233
234
end
···
235
236
Signal.trap("SIGPIPE", "SYSTEM_DEFAULT")
236
237
printer = PostConsolePrinter.new(feed)
237
238
238
-
matched_posts.each do |p|
239
+
matched_posts.reverse.each do |p|
239
240
printer.display(p)
240
241
end
241
242