diff --git a/app/controllers/admin/raffles/participants_controller.rb b/app/controllers/admin/raffles/participants_controller.rb index cd87171b1..e1723c978 100644 --- a/app/controllers/admin/raffles/participants_controller.rb +++ b/app/controllers/admin/raffles/participants_controller.rb @@ -285,7 +285,7 @@ def participants_scope term = "%#{ActiveRecord::Base.sanitize_sql_like(@query)}%" participants.left_outer_joins(:user) - .where("users.display_name ILIKE :term OR raffle_participants.code ILIKE :term OR raffle_participants.github_login ILIKE :term", term: term) + .where("users.display_name ILIKE :term OR raffle_participants.code ILIKE :term OR raffle_participants.github_login ILIKE :term OR raffle_participants.github_email ILIKE :term", term: term) end def query_param diff --git a/app/views/admin/raffles/participants/index.html.erb b/app/views/admin/raffles/participants/index.html.erb index 9fe73e68d..2df8b5d30 100644 --- a/app/views/admin/raffles/participants/index.html.erb +++ b/app/views/admin/raffles/participants/index.html.erb @@ -4,13 +4,13 @@

Participants

<%= form_with url: admin_raffles_participants_path, method: :get do %> - <%= text_field_tag :query, @query, placeholder: "display name or code", autocomplete: "off" %> + <%= text_field_tag :query, @query, placeholder: "name, code, or email", autocomplete: "off" %> <%= submit_tag "Search" %> <% end %> - + <% @participants.each do |participant| %> @@ -18,6 +18,7 @@ + diff --git a/app/views/admin/raffles/participants/show.html.erb b/app/views/admin/raffles/participants/show.html.erb index 827f17e82..2bfbcce08 100644 --- a/app/views/admin/raffles/participants/show.html.erb +++ b/app/views/admin/raffles/participants/show.html.erb @@ -12,6 +12,7 @@
  • Signed up: <%= @participant.user.created_at.strftime("%Y-%m-%d %H:%M UTC") %>
  • <% else %>
  • GitHub: <%= @participant.github_login %>
  • +
  • GitHub email: <%= @participant.github_email || "—" %>
  • <% end %>
  • Eligible: <%= @participant.eligible? ? "Yes" : "No" %>
  • <% if @participant.fraud_cleared? %> diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 5bb858e83..a6113cc2f 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -58,7 +58,7 @@ def callback_url ENV["RAFFLE_GITHUB_CLIENT_ID"] || Rails.application.credentials.dig(:github_raffle, :client_id), ENV["RAFFLE_GITHUB_CLIENT_SECRET"] || Rails.application.credentials.dig(:github_raffle, :client_secret), { - scope: "read:user", + scope: "read:user user:email", callback_path: "/auth/github/callback" } end diff --git a/db/migrate/20260710200000_add_github_email_to_raffle_participants.rb b/db/migrate/20260710200000_add_github_email_to_raffle_participants.rb new file mode 100644 index 000000000..414b10232 --- /dev/null +++ b/db/migrate/20260710200000_add_github_email_to_raffle_participants.rb @@ -0,0 +1,5 @@ +class AddGithubEmailToRaffleParticipants < ActiveRecord::Migration[8.0] + def change + add_column :raffle_participants, :github_email, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index d09da7493..1ef540aba 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_07_08_183407) do +ActiveRecord::Schema[8.1].define(version: 2026_07_10_200000) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" enable_extension "vector" @@ -859,6 +859,7 @@ t.boolean "eligible", default: true, null: false t.boolean "fraud_cleared", default: false, null: false t.string "github_avatar_url" + t.string "github_email" t.string "github_login" t.string "github_uid" t.bigint "signup_week_id" diff --git a/engines/raffle/app/controllers/raffle/sessions_controller.rb b/engines/raffle/app/controllers/raffle/sessions_controller.rb index 88249ccea..c2a0a0c2a 100644 --- a/engines/raffle/app/controllers/raffle/sessions_controller.rb +++ b/engines/raffle/app/controllers/raffle/sessions_controller.rb @@ -26,6 +26,7 @@ def dev_login handle = params[:handle].presence&.parameterize(separator: "_")&.first(40) || "dev-adult" participant = Raffle::Participant.find_or_create_by!(github_uid: "dev-#{handle}") do |p| p.github_login = handle + p.github_email = "#{handle}@example.com" p.age_group = :adult end session[:raffle_participant_id] = participant.id diff --git a/engines/raffle/app/models/raffle/participant.rb b/engines/raffle/app/models/raffle/participant.rb index 2ce81aa60..888d1fe44 100644 --- a/engines/raffle/app/models/raffle/participant.rb +++ b/engines/raffle/app/models/raffle/participant.rb @@ -46,6 +46,7 @@ def self.from_github(auth) participant = find_or_initialize_by(github_uid: uid) participant.github_login = login participant.github_avatar_url = info&.image + participant.github_email = info&.email participant.age_group = :adult participant.save! participant diff --git a/engines/raffle/app/views/raffle/shared/_dev_panel.html.erb b/engines/raffle/app/views/raffle/shared/_dev_panel.html.erb index db018bc57..b63688d4e 100644 --- a/engines/raffle/app/views/raffle/shared/_dev_panel.html.erb +++ b/engines/raffle/app/views/raffle/shared/_dev_panel.html.erb @@ -44,6 +44,9 @@ <% if enrolled? %> +
    + GitHub email: <%= current_participant.github_email || "(none)" %> +
    Add demo referrals (to you) <%= form_with url: dev_referrals_path, method: :post, class: "raffle-dev__refform" do %>
    UserCodeTypeCountryEligibleReferralsJoined
    UserCodeTypeEmailCountryEligibleReferralsJoined
    <%= link_to participant.display_name, admin_raffles_participant_path(participant) %> <%= participant.code %> <%= participant.age_group %><%= participant.github_email || participant.user&.email || "—" %> <%= participant.user&.geocoded_country || "—" %> <%= participant.eligible? ? "Yes" : "No" %> <%= @referral_counts[participant.id].to_i %>