Skip to content

Commit

Permalink
Add demographics to check-ins this week
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwofford committed Feb 6, 2018
1 parent 5e327d6 commit 00fc1f2
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 10 deletions.
82 changes: 73 additions & 9 deletions api/app/models/hackbot/interactions/check_in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,84 @@ def wait_for_attendance
copy('judgement.amazing')
end

msg_channel(
text: copy('attendance.valid', judgement: judgement),
attachments: [
actions: [
{ text: 'Yes' },
{ text: 'No' }
]
]
)
msg_channel text: copy('attendance.valid', judgement: judgement)
msg_channel copy('demographics.introduction')
msg_channel copy('demographics.women')

default_follow_up 'wait_for_women_demographics'
:wait_for_women_demographics
end

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
def wait_for_women_demographics
msg_wo_percent_sign = msg.tr('%', '')

unless integer?(msg_wo_percent_sign) && msg.include?('%')
msg_channel copy('demographics.not_percentage')

default_follow_up 'wait_for_women_demographics'
return :wait_for_women_demographics
end

percent = msg_wo_percent_sign.to_i
if percent < 0 || percent > 100
msg_channel copy('demographics.out_of_bounds', percent: percent)

default_follow_up 'wait_for_women_demographics'
return :wait_for_women_demographics
end

data['percent_women'] = percent
msg_channel copy('demographics.confirm_recorded',
percent: percent,
metric: 'women')
msg_channel copy('demographics.racial_minority')

default_follow_up 'wait_for_racial_minority_demographics'
:wait_for_racial_minority_demographics
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
def wait_for_racial_minority_demographics
msg_wo_percent_sign = msg.tr('%', '')
unless integer?(msg_wo_percent_sign) && msg.include?('%')
msg_channel copy('demographics.not_percentage')

default_follow_up 'wait_for_racial_minority_demographics'
return :wait_for_racial_minority_demographics
end

percent = msg_wo_percent_sign.to_i
if percent < 0 || percent > 100
msg_channel copy('demographics.out_of_bounds', percent: percent)

default_follow_up 'wait_for_racial_minority_demographics'
return :wait_for_racial_minority_demographics
end

data['percent_racial_minority'] = percent
msg_channel copy('demographics.confirm_recorded',
percent: percent,
metric: 'not white or Asian')
msg_channel(text: copy('demographics.finished'),
attachments: [
actions: [
{ text: 'Yes' },
{ text: 'No' }
]
])

default_follow_up 'wait_for_notes_confirmation'
:wait_for_notes_confirmation
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength

# rubocop:disable Metrics/MethodLength
def wait_for_notes_confirmation
return :wait_for_notes_confirmation unless action

Expand Down
16 changes: 15 additions & 1 deletion api/lib/data/copy/check_in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,21 @@ attendance:
not_realistic:
negative: I'm going to need a positive number, silly. How many people came to the last meeting?
too_large: That number is too big for our database! How many people actually came to your last meeting?
valid: <%= judgement %> Is there anything the Hack Club team can be helpful with?
valid: <%= judgement %>

demographics:
introduction: Hack Club HQ is applying for a grant this week and the foundation is asking for demographic info from every club, so I need to ask you a couple follow-up questions. Estimates are OK.
women: What percentage of your members are women?
racial_minority: What percentage are a racial minority in the technology industry, defined as not being white or Asian?
confirm_recorded:
- Okay, *<%= percent %>%* of your attendees are <%= metric %>.
- Got it. I've recorded that *<%= percent %>%* of your hackers are <%= metric %>.
- Gotcha, *<%= percent %>%* of your club's attendees are <%= metric %>.
- '*<%= percent %>%* of your club members are <%= metric %>.'
- I'm writing down that *<%= percent %>%* of your club members are <%= metric %>.
not_percentage: I don't understand that too well. Can you tell me in the format `x%` where x is a number from 0 to 100? For example, `75%`.
out_of_bounds: <%= percent %>%? Percentages should be from 0 to 100.
finished: Is there anything the Hack Club team can be helpful with?

notes_confirmation:
has_notes:
Expand Down

0 comments on commit 00fc1f2

Please sign in to comment.