Skip to content

Commit

Permalink
Merge pull request #2407 from cloudnativedaysjp/feat/add-scanner-prof…
Browse files Browse the repository at this point in the history
…ile-id

チェックイン時に受付担当の人のprofile idも保存する
  • Loading branch information
jacopen authored Oct 6, 2024
2 parents e68d8c3 + ba2b2d7 commit 2661a60
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/check_in_conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def create
@params = check_in_conferences_params(JSON.parse(request.body.read, { symbolize_names: true }))
profile = Profile.find(@params[:profileId])
check_in_timestamp = Time.zone.at(@params[:checkInTimestamp])
@check_in = CheckInConference.new(profile:, conference:, check_in_timestamp:)
@check_in = CheckInConference.new(profile:, conference:, check_in_timestamp:, scanner_profile_id: profile.id)

if @check_in.save
render(json: @check_in, status: :created)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/check_in_talks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create
talk = Talk.find(@params[:talkId])
profile = Profile.find(@params[:profileId])
check_in_timestamp = Time.zone.at(@params[:checkInTimestamp])
@check_in = CheckInTalk.new(profile:, talk:, check_in_timestamp:)
@check_in = CheckInTalk.new(profile:, talk:, check_in_timestamp:, scanner_profile_id: profile.id)

if @check_in.save
render(json: @check_in, status: :created)
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/concerns/secured_public_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ def conference
def set_conference
conference
end

def profile
@profile ||= Profile.find_by(email: @current_user[:info][:email], conference_id: conference.id)
end
end
2 changes: 2 additions & 0 deletions app/models/check_in_conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# updated_at :datetime not null
# conference_id :bigint not null
# profile_id :bigint not null
# scanner_profile_id :bigint
#
# Indexes
#
Expand All @@ -22,4 +23,5 @@
class CheckInConference < ApplicationRecord
belongs_to :conference
belongs_to :profile
belongs_to :scanner_profile, optional: true, class_name: 'Profile'
end
2 changes: 2 additions & 0 deletions app/models/check_in_talk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# created_at :datetime not null
# updated_at :datetime not null
# profile_id :bigint not null
# scanner_profile_id :bigint
# talk_id :bigint not null
#
# Indexes
Expand All @@ -22,4 +23,5 @@
class CheckInTalk < ApplicationRecord
belongs_to :talk
belongs_to :profile
belongs_to :scanner_profile, optional: true, class_name: 'Profile'
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddScannerProfileIdColumnsToCheckIns < ActiveRecord::Migration[7.0]
def change
add_column :check_in_conferences, :scanner_profile_id, :bigint, null: true
add_column :check_in_talks, :scanner_profile_id, :bigint, null: true
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_09_05_140927) do
ActiveRecord::Schema[7.0].define(version: 2024_09_26_095613) do
create_table "admin_profiles", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "conference_id", null: false
t.string "sub"
Expand Down Expand Up @@ -70,6 +70,7 @@
t.datetime "check_in_timestamp", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "scanner_profile_id"
t.index ["conference_id"], name: "index_check_in_conferences_on_conference_id"
t.index ["profile_id"], name: "index_check_in_conferences_on_profile_id"
end
Expand All @@ -80,6 +81,7 @@
t.datetime "check_in_timestamp", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "scanner_profile_id"
t.index ["profile_id"], name: "index_check_in_talks_on_profile_id"
t.index ["talk_id"], name: "index_check_in_talks_on_talk_id"
end
Expand Down

0 comments on commit 2661a60

Please sign in to comment.