Skip to content

Commit

Permalink
chore: try to create badge on track / quest created
Browse files Browse the repository at this point in the history
  • Loading branch information
juliano-quatrin-nunes committed Jan 10, 2025
1 parent 6a20a26 commit 190299a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ def call(event)
display_data: event.data[:display_data]
)

badge_id = SecureRandom.uuid
Rewarding::BadgeReadModel.create!(
badge_id: badge_id,
display_data: event.data[:badge_display_data],
badgeable: quest
)
Rails.logger.info "Quest created in read model: #{quest.quest_id}"
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
module Questing
class OnTrackCreated
def call(event)
track = TrackReadModel.create!(
TrackReadModel.create!(
track_id: event.data[:track_id],
display_data: event.data[:display_data],
quest_ids: event.data[:quest_ids]
)

badge_id = SecureRandom.uuid
Rewarding::BadgeReadModel.create!(
badge_id: badge_id,
display_data: event.data[:badge_display_data],
badgeable: track
)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Rewarding
class OnQuestCreated
def call(event)
BadgeReadModel.create!(
badge_id: SecureRandom.uuid,
display_data: event.data[:badge_display_data],
badgeable_type: "Questing::QuestReadModel",
badgeable_id: event.data[:quest_id]
)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Rewarding
class OnTrackCreated
def call(event)
BadgeReadModel.create!(
badge_id: SecureRandom.uuid,
display_data: event.data[:badge_display_data],
badgeable_type: "Questing::TrackReadModel",
badgeable_id: event.data[:track_id]
)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class ReadModelConfiguration
def call(event_store)
event_store.subscribe(OnRewardPoolCreated, to: [Rewarding::RewardPoolCreated])
event_store.subscribe(OnRewardIssued, to: [Rewarding::RewardIssued])
event_store.subscribe(OnQuestCreated, to: [Questing::QuestCreated])
event_store.subscribe(OnTrackCreated, to: [Questing::TrackCreated])
end
end
end

0 comments on commit 190299a

Please sign in to comment.