-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
351d5e8
commit 51c06d4
Showing
18 changed files
with
177 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the editions controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: https://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class EditionsController < ApplicationController | ||
def show | ||
edition_id = params[:id] | ||
|
||
render :show, locals: { | ||
edition_id: edition_id, | ||
participants: EditionParticipant.where(edition_id: edition_id), | ||
edition_status: EditionStatus.find_by(edition_id: edition_id) | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module EditionsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class EditionParticipant < ApplicationRecord | ||
def self.handle_participant_event(event) | ||
edition_id = event.data[:edition_id] | ||
participant_id = event.data[:participant_id] | ||
|
||
case event | ||
when Workshops::ParticipantPersonalDataProvided | ||
where(participant_id: participant_id).update_all( | ||
participant_name: event.data[:name], | ||
participant_email: event.data[:email] | ||
) | ||
when Workshops::ParticipantRegisteredForEdition | ||
find_or_create_by(edition_id: edition_id, participant_id: participant_id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class EditionStatus < ApplicationRecord | ||
def self.handle_confirmed_event(e) | ||
edition_id = e.data[:edition_id] | ||
find_or_create_by(edition_id: edition_id).update(status: "confirmed") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<h1>Edition <%= edition_id %>: <%= edition_status.status %></h1> | ||
|
||
<h3><%= participants.size %></h3> | ||
|
||
<table> | ||
<% participants.each do |p| %> | ||
<tr> | ||
<td><%= p.participant_id %></td> | ||
<td><%= p.participant_name %></td> | ||
<td><%= p.participant_email %></td> | ||
</tr> | ||
<% end %> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
Rails.application.routes.draw do | ||
mount RailsEventStore::Browser => '/res' if Rails.env.development? | ||
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html | ||
|
||
get '/editions/:id', to: 'editions#show' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateEditionStatuses < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :edition_statuses do |t| | ||
t.string :edition_id | ||
t.string :status | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateEditionParticipants < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :edition_participants do |t| | ||
t.string :edition_id | ||
t.string :participant_id | ||
t.string :participant_name | ||
t.string :participant_email | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
event_store = Rails.configuration.event_store | ||
edition_id = "smart-pension" | ||
stream_name = "Edition$#{edition_id}" | ||
|
||
EditionParticipant.delete_all | ||
EditionStatus.delete_all | ||
|
||
event_store.publish( | ||
Workshops::EditionConfirmed.new(data: { edition_id: edition_id }), | ||
stream_name: stream_name | ||
) | ||
event_store.publish( | ||
Workshops::ParticipantRegisteredForEdition.new(data: { edition_id: edition_id, participant_id: pid1 = SecureRandom.uuid }), | ||
stream_name: stream_name | ||
) | ||
event_store.publish( | ||
Workshops::ParticipantRegisteredForEdition.new(data: { edition_id: edition_id, participant_id: pid2 = SecureRandom.uuid }), | ||
stream_name: stream_name | ||
) | ||
event_store.publish( | ||
Workshops::ParticipantPersonalDataProvided.new(data: { participant_id: pid1, name: 'Tom', email: 't@acme' }), | ||
stream_name: stream_name | ||
) | ||
event_store.publish( | ||
Workshops::ParticipantPersonalDataProvided.new(data: { participant_id: pid2, name: 'Jerry', email: 'j@acme' }), | ||
stream_name: stream_name | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class EditionsControllerTest < ActionDispatch::IntegrationTest | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the '{}' from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the '{}' from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class EditionParticipantTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class EditionStatusTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters