0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/plugins/discourse-reactions/db/fixtures/001_badges.rb
2025-07-10 11:40:31 +01:00

27 lines
853 B
Ruby
Vendored

# frozen_string_literal: true
first_reaction_query = <<~SQL
SELECT user_id, created_at AS granted_at, post_id
FROM (
SELECT ru.post_id, ru.user_id, ru.created_at,
ROW_NUMBER() OVER (PARTITION BY ru.user_id ORDER BY ru.created_at) AS row_number
FROM discourse_reactions_reaction_users ru
JOIN badge_posts p ON ru.post_id = p.id
WHERE :backfill
OR ru.post_id IN (:post_ids)
) x
WHERE row_number = 1
SQL
Badge.seed(:name) do |b|
b.name = "First Reaction"
b.default_icon = "face-smile"
b.badge_type_id = BadgeType::Bronze
b.multiple_grant = false
b.target_posts = true
b.show_posts = true
b.query = first_reaction_query
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
b.trigger = Badge::Trigger::PostRevision
b.system = true
end