mirror of
https://github.com/discourse/discourse.git
synced 2025-06-07 20:16:04 +08:00
FIX: Featuring topics wasn't happy with concurrency.
This commit is contained in:
@ -40,7 +40,11 @@ class CategoryFeaturedTopic < ActiveRecord::Base
|
|||||||
CategoryFeaturedTopic.delete_all(category_id: c.id)
|
CategoryFeaturedTopic.delete_all(category_id: c.id)
|
||||||
if results
|
if results
|
||||||
results.each_with_index do |topic_id, idx|
|
results.each_with_index do |topic_id, idx|
|
||||||
|
begin
|
||||||
c.category_featured_topics.create(topic_id: topic_id, rank: idx)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user