tangled
alpha
login
or
join now
mackuba.eu
/
lycan
35
fork
atom
Don't forget to lycansubscribe
35
fork
atom
overview
issues
1
pulls
pipelines
skip likes whose posts don't pass validation
mackuba.eu
6 months ago
b8c713b1
b0e1fc64
+19
-4
1 changed file
expand all
collapse all
unified
split
app
post_downloader.rb
+19
-4
app/post_downloader.rb
···
50
items.delete(item)
51
52
post = save_post(data['uri'], data['record'])
53
-
update_item(item, post)
0
0
0
0
0
0
54
rescue StandardError => e
55
-
puts "Error in PostDownloader: #{item.post_uri}: #{e}"
56
end
57
end
58
rescue StandardError => e
59
-
puts "Error in PostDownloader: #{e}"
60
end
61
end
62
end
···
69
70
author = User.find_or_create_by!(did: did)
71
72
-
Post.create!(
73
user: author,
74
rkey: rkey,
75
time: Time.parse(created),
···
85
@oldest_imported = [@oldest_imported, item.time].min
86
87
@report&.update(downloader: { downloaded_posts: @total_count, oldest_date: @oldest_imported })
0
0
0
0
0
0
0
0
0
88
end
89
end
···
50
items.delete(item)
51
52
post = save_post(data['uri'], data['record'])
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
60
rescue StandardError => e
61
+
puts "Error in PostDownloader: #{item.post_uri}: #{e.class}: #{e}"
62
end
63
end
64
rescue StandardError => e
65
+
puts "Error in PostDownloader: #{e.class}: #{e}"
66
end
67
end
68
end
···
75
76
author = User.find_or_create_by!(did: did)
77
78
+
Post.create(
79
user: author,
80
rkey: rkey,
81
time: Time.parse(created),
···
91
@oldest_imported = [@oldest_imported, item.time].min
92
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
103
end
104
end