Skip to content

Commit 20e4f0e

Browse files
committed
get rid of code we aren't using right now that was throwing errors
1 parent c11eb9c commit 20e4f0e

File tree

6 files changed

+79
-61
lines changed

6 files changed

+79
-61
lines changed

app/admin/users.rb

+9-7
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,24 @@ def import_data
116116
@users = []
117117
@attributes = UserConstants::COLUMN_NAMES_FOR_DISPLAY
118118
CSV.foreach(params[:file].path, headers: true) do |row|
119-
table_type = params["airtable_type"]
119+
# table_type = params["airtable_type"]
120120
airtable_id = row["Record ID"]
121121
if row[0].present?
122122

123-
if table_type == "admin"
124-
airtable_user = AirtableUserFromAdmin.find(airtable_id)
125-
user = User.find_or_initialize_by(email: airtable_user["Contact E-Mail"])
126-
elsif table_type == "prog_apps"
123+
# if table_type == "admin"
124+
# airtable_user = AirtableUserFromAdmin.find(airtable_id)
125+
# user = User.find_or_initialize_by(email: airtable_user["Contact E-Mail"])
126+
# elsif table_type == "prog_apps"
127127
airtable_user = AirtableUser.find(airtable_id)
128128
user = User.where(airtable_id: airtable_id).first
129129
if user.blank?
130130
user = User.find_or_initialize_by(email: airtable_user["Contact E-Mail"])
131131
end
132132
user.airtable_id = airtable_id
133-
end
134-
user.sync_with_airtable(airtable_user, table_type)
133+
# end
134+
user.sync_with_airtable(airtable_user
135+
# , table_type
136+
)
135137
@users << user
136138
end
137139
end
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Airrecord.api_key = ENV['AIRTABLE_API_KEY']
22

33

4-
class AirtableUserFromAdmin < Airrecord::Table
5-
self.base_key = ENV['AIRTABLE_ADMIN_BASE_KEY']
6-
self.table_name = ENV['AIRTABLE_ADMIN_TABLE_NAME']
4+
# class AirtableUserFromAdmin < Airrecord::Table
5+
# self.base_key = ENV['AIRTABLE_ADMIN_BASE_KEY']
6+
# self.table_name = ENV['AIRTABLE_ADMIN_TABLE_NAME']
77

8-
end
8+
# end

app/models/user.rb

+37-33
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ def airtable_twin
178178
end
179179
end
180180

181-
def sync_with_airtable(airtable_user, airtable_table)
181+
def sync_with_airtable(airtable_user
182+
# , airtable_table
183+
)
182184
self.skip_push_to_airtable = true
183185

184186
if self.new_record?
@@ -230,41 +232,43 @@ def sync_with_airtable(airtable_user, airtable_table)
230232
self.get_slack_username
231233
end
232234

233-
elsif airtable_table == "admin"
234-
self.assign_attributes({
235-
name: airtable_user["Name"],
236-
read_code_of_conduct: airtable_user["Read Code of Conduct"],
237-
anonymous: airtable_user["I prefer to remain anonymous."],
238-
welcome_email_sent: airtable_user["Welcome E-mail Sent"],
239-
attended_onboarding: airtable_user["Attended Onboarding"],
240-
slack_invite_sent: airtable_user["Slack invite sent?"],
241-
requested_additional_verification: airtable_user["Requested additional verification"],
242-
decline_membership: airtable_user["Declime Membership"],
243-
irs_email_sent: airtable_user["IRS Email Sent"],
244-
internal_notes: airtable_user["Internal Notes"],
245-
contributor: airtable_user["Contributor?"],
246-
email: airtable_user["Contact E-Mail"],
247-
verification_urls: airtable_user["Verification URLs"],
248-
hear_about_us: airtable_user["How did you hear about us?"],
249-
referrer_name: airtable_user["Name of ProgCode member who referred you."],
250-
skills_and_experience: airtable_user["Skills and Relevant Experience (Tech or Non-Tech)"],
251-
join_reason: airtable_user["Bio"],
252-
phone: airtable_user["Phone"],
253-
optin: airtable_user["Opt In to Anonymized Member Directory"],
254-
location: airtable_user["Location"],
255-
read_manifesto: airtable_user["Read Manifesto"]
256-
})
257-
258-
if self.decline_membership
259-
self.is_approved = false
260-
elsif self.welcome_email_sent
261-
self.is_approved = true
262-
end
235+
# elsif airtable_table == "admin"
236+
# self.assign_attributes({
237+
# name: airtable_user["Name"],
238+
# read_code_of_conduct: airtable_user["Read Code of Conduct"],
239+
# anonymous: airtable_user["I prefer to remain anonymous."],
240+
# welcome_email_sent: airtable_user["Welcome E-mail Sent"],
241+
# attended_onboarding: airtable_user["Attended Onboarding"],
242+
# slack_invite_sent: airtable_user["Slack invite sent?"],
243+
# requested_additional_verification: airtable_user["Requested additional verification"],
244+
# decline_membership: airtable_user["Declime Membership"],
245+
# irs_email_sent: airtable_user["IRS Email Sent"],
246+
# internal_notes: airtable_user["Internal Notes"],
247+
# contributor: airtable_user["Contributor?"],
248+
# email: airtable_user["Contact E-Mail"],
249+
# verification_urls: airtable_user["Verification URLs"],
250+
# hear_about_us: airtable_user["How did you hear about us?"],
251+
# referrer_name: airtable_user["Name of ProgCode member who referred you."],
252+
# skills_and_experience: airtable_user["Skills and Relevant Experience (Tech or Non-Tech)"],
253+
# join_reason: airtable_user["Bio"],
254+
# phone: airtable_user["Phone"],
255+
# optin: airtable_user["Opt In to Anonymized Member Directory"],
256+
# location: airtable_user["Location"],
257+
# read_manifesto: airtable_user["Read Manifesto"]
258+
# })
259+
260+
# if self.decline_membership
261+
# self.is_approved = false
262+
# elsif self.welcome_email_sent
263+
# self.is_approved = true
264+
# end
263265

264-
end
266+
# end
265267

266268
if self.email.present? || self.slack_userid.present?
267-
all_airtable_users = airtable_table == 'admin' ? AirtableUserFromAdmin.all : AirtableUser.all
269+
all_airtable_users = AirtableUser.all
270+
# airtable_table == 'admin' ? AirtableUserFromAdmin.all :
271+
268272
matches = all_airtable_users.select {|u| (self.email.present? && u["Contact E-Mail"] == self.email) || (self.slack_userid.present? && u["slack_id"] == self.slack_userid)}
269273
if matches.length > 1
270274
self.flags << "This user appears more than once in Airtable"
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<h1>Import <%= controller_name.singularize.titleize %> Data from Airtable</h1>
22
<%= form_tag({:controller => controller_path, :action => 'import_data'}, multipart: true) do %>
33
<div class="row"><%= file_field_tag :file, :class => "btn" %></div>
4-
<div class="row"><%= label_tag 'airtable_type_prog_apps', 'From Prog Apps Table' %>
5-
<%= radio_button_tag 'airtable_type', 'prog_apps', true %>
6-
</div>
4+
<%# <div class="row"><%= label_tag 'airtable_type_prog_apps', 'From Prog Apps Table' %>
5+
<%# <%= radio_button_tag 'airtable_type', 'prog_apps', true %>
6+
<%# </div> %>
77
<div class="row">
8-
<%= label_tag 'airtable_type_admin', 'From Admin Table' %>
9-
<%= radio_button_tag 'airtable_type', 'admin' %></div>
8+
<%# <%= label_tag 'airtable_type_admin', 'From Admin Table' %>
9+
<%# <%= radio_button_tag 'airtable_type', 'admin' %>
10+
<%# </div> %>
1011
<div class="row"><%= hidden_field_tag :confirmation, "pending" %>
1112
<%= submit_tag "Import", :class => "btn", :disabled => true %></div>
1213
<% end %>

db/schema.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2020_09_25_025920) do
13+
ActiveRecord::Schema.define(version: 2021_02_19_040742) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -165,6 +165,16 @@
165165
t.string "airtable_id"
166166
t.string "secure_token"
167167
t.string "flags", default: [], array: true
168+
t.boolean "welcome_email_sent"
169+
t.boolean "attended_onboarding"
170+
t.boolean "slack_invite_sent"
171+
t.boolean "requested_additional_verification"
172+
t.boolean "decline_membership"
173+
t.boolean "irs_email_sent"
174+
t.text "internal_notes"
175+
t.boolean "contributor"
176+
t.string "referrer_name"
177+
t.text "skills_and_experience"
168178
t.index ["airtable_id"], name: "index_users_on_airtable_id", unique: true
169179
t.index ["email"], name: "index_users_on_email", unique: true
170180
t.index ["referer_id"], name: "index_users_on_referer_id"

lib/tasks/import_users_task.rb

+12-11
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ def sync
3232
end
3333
end
3434

35-
def admin_sync
36-
AirtableUserFromAdmin.all.each do |airtable_user|
37-
if airtable_user["Contact E-Mail"].blank?
38-
puts "Email not in record: #{airtable_user.inspect}"
39-
next
40-
else
41-
user = User.find_or_initialize_by email: airtable_user["Contact E-Mail"]
35+
#not going to import users from here for now
36+
# def admin_sync
37+
# AirtableUserFromAdmin.all.each do |airtable_user|
38+
# if airtable_user["Contact E-Mail"].blank?
39+
# puts "Email not in record: #{airtable_user.inspect}"
40+
# next
41+
# else
42+
# user = User.find_or_initialize_by email: airtable_user["Contact E-Mail"]
4243

43-
user.sync_with_airtable(airtable_user, 'admin')
44-
end
45-
end
46-
end
44+
# user.sync_with_airtable(airtable_user, 'admin')
45+
# end
46+
# end
47+
# end
4748

4849
end
4950
end

0 commit comments

Comments
 (0)