Don't forget to lycansubscribe

skip likes whose posts don't pass validation

Changed files
+19 -4
app
+19 -4
app/post_downloader.rb
··· 50 50 items.delete(item) 51 51 52 52 post = save_post(data['uri'], data['record']) 53 - update_item(item, post) 53 + 54 + if post.valid? 55 + update_item(item, post) 56 + else 57 + puts "Invalid post #{item.post_uri}: #{post.errors.full_messages.join("; ")}" 58 + invalidate_item(item) 59 + end 54 60 rescue StandardError => e 55 - puts "Error in PostDownloader: #{item.post_uri}: #{e}" 61 + puts "Error in PostDownloader: #{item.post_uri}: #{e.class}: #{e}" 56 62 end 57 63 end 58 64 rescue StandardError => e 59 - puts "Error in PostDownloader: #{e}" 65 + puts "Error in PostDownloader: #{e.class}: #{e}" 60 66 end 61 67 end 62 68 end ··· 69 75 70 76 author = User.find_or_create_by!(did: did) 71 77 72 - Post.create!( 78 + Post.create( 73 79 user: author, 74 80 rkey: rkey, 75 81 time: Time.parse(created), ··· 85 91 @oldest_imported = [@oldest_imported, item.time].min 86 92 87 93 @report&.update(downloader: { downloaded_posts: @total_count, oldest_date: @oldest_imported }) 94 + end 95 + 96 + def invalidate_item(item) 97 + @total_count += 1 98 + @oldest_imported = [@oldest_imported, item.time].min 99 + 100 + @report&.update(downloader: { downloaded_posts: @total_count, oldest_date: @oldest_imported }) 101 + 102 + item.destroy 88 103 end 89 104 end