FIX: Featuring topics wasn't happy with concurrency.

This commit is contained in:
Robin Ward 2016-05-03 14:24:50 -04:00
parent 26964a72ca
commit 2cc6efba8c
No known key found for this signature in database
GPG key ID: 0E091E2B4ED1B83D

View file

@ -40,7 +40,11 @@ class CategoryFeaturedTopic < ActiveRecord::Base
CategoryFeaturedTopic.delete_all(category_id: c.id)
if results
results.each_with_index do |topic_id, idx|
c.category_featured_topics.create(topic_id: topic_id, rank: idx)
begin
c.category_featured_topics.create(topic_id: topic_id, rank: idx)
rescue PG::UniqueViolation
# If another process features this topic, just ignore it
end
end
end
end