/pool_versions: fix exception in pool diffs.

https://danbooru.donmai.us/forum_topics/9127?page=280#forum_post_159633
This commit is contained in:
evazion
2019-09-10 14:58:12 -05:00
parent e815f46d2a
commit 372fd7df1b
3 changed files with 20 additions and 7 deletions

View File

@@ -62,19 +62,18 @@ class PoolArchive < ApplicationRecord
sqs_service.send_message(msg, message_group_id: "pool:#{pool.id}")
end
def build_diff(other = nil)
def build_diff(other = previous)
diff = {}
prev = previous
if prev.nil?
if other.nil?
diff[:added_post_ids] = added_post_ids
diff[:removed_post_ids] = removed_post_ids
diff[:added_desc] = description
else
diff[:added_post_ids] = post_ids - prev.post_ids
diff[:removed_post_ids] = prev.post_ids - post_ids
diff[:added_post_ids] = post_ids - other.post_ids
diff[:removed_post_ids] = other.post_ids - post_ids
diff[:added_desc] = description
diff[:removed_desc] = prev.description
diff[:removed_desc] = other.description
end
diff