Skip to content

Commit

Permalink
Motivate people who have never filled out their profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-burns committed Nov 13, 2010
1 parent ba6f44e commit 444faaf
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 5 deletions.
2 changes: 2 additions & 0 deletions TODO
Expand Up @@ -11,6 +11,8 @@
Gender breakdown
* HTTP auth for /secretsecret

* Bug people who have never filled out their profile. This is implemented but does not work for existing users.


Lead generation ideas:
* scrape craigslist
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/users_controller.rb
@@ -1,4 +1,6 @@
class UsersController < ApplicationController
before_filter :edit_empty_profile, :only => :create

def new
@user = User.new
end
Expand Down Expand Up @@ -27,4 +29,11 @@ def update
render :action => :edit
end
end

protected

def edit_empty_profile
user = User.find_by_phone_number(params[:user][:phone_number])
redirect_to edit_user_path(user.id) if user.try(:incomplete?)
end
end
13 changes: 13 additions & 0 deletions app/models/profile_annoyer.rb
@@ -0,0 +1,13 @@
class ProfileAnnoyer
@queue = :annoyer

def self.perform(args_hash)
user_id = args_hash["user_id"]
user = User.find(user_id)

if user.incomplete?
user.tell("Hey you need to fill out your instalover profile! Go back and entre your phone number, or quit forever with 'safeword'.")
QUEUE.enqueue_at(1.day.from_now, ProfileAnnoyer, :user_id => user.id)
end
end
end
10 changes: 9 additions & 1 deletion app/models/user.rb
Expand Up @@ -12,7 +12,7 @@ class User < ActiveRecord::Base

before_validation :secret_code, :on => :create
before_validation :normalize_phone_number
after_create :deliver_secret_code
after_create :deliver_secret_code, :start_annoyer
after_save :deliver_confirmation_congratulations

has_many :founded_meetups, :class_name => 'Meetup', :foreign_key => 'first_user_id', :dependent => :destroy
Expand Down Expand Up @@ -117,6 +117,10 @@ def tell(msg)
Message.deliver(self.phone_number, msg)
end

def incomplete?
dob.nil?
end

protected

def normalize_phone_number
Expand Down Expand Up @@ -200,4 +204,8 @@ def deliver_confirmation_congratulations
self.tell("Congrats, #{self.name}, you are now an instalover. Text '#{COMMANDS[:new_date]}' to get a new date.")
end
end

def start_annoyer
QUEUE.enqueue_at(7.days.from_now, ProfileAnnoyer, :user_id => self.id)
end
end
46 changes: 46 additions & 0 deletions features/motivators.feature
@@ -0,0 +1,46 @@
Feature: Motivate people to use this service

As of Nov 12, 2010:
| total | no profile | asked for zero dates | asked for one date | asked for more than one date | have zero matches |
| 109 | 49 | 81 | 11 | 17 | 59, 77, 111 |
User 59 is looking for other but we have no others
Advertise to sex-positive communities?
User 77 is looking for 18-21 y/o women
User 111 is looking for 18-20 y/o women
Advertise to college freshmen?

Scenario: Annoy the people who have never filled out their profile
Given the day and time is "November 12, 2010 01:00 est"
Given the following empty user exists:
| phone number | secret code |
| 18004688487 | tits |
And the day and time is "November 18, 2010 01:00 est"
Then "18004688487" should not get a text whose message includes "fill out"
When it is 24 hours later
And timed jobs are processed
Then "18004688487" should get a text whose message includes "fill out"
Given I clear the text message history
When it is 24 hours later
And timed jobs are processed
Then "18004688487" should get a text whose message includes "fill out"

When I go to the home page
And I fill in "18004688487" as my phone number
And I press the text me button
And I fill in the secret code "tits"
And I fill in the date of birth with "November 12, 1983"
And I fill in my name as "Mike"
And I check my gender as male
And I fill in the minimum age with "21"
And I fill in the maximum age with "34"
And I check my desired gender as female
And I submit my profile
Then I see a welcome page

Given I clear the text message history
When it is 24 hours later
And timed jobs are processed
Then "18004688487" should not get a text whose message includes "fill out"

@wip
Scenario: Ask out those who have asked for one date on behalf of those who have asked out none
4 changes: 4 additions & 0 deletions features/step_definitions/form_steps.rb
Expand Up @@ -14,6 +14,10 @@
fill_in 'user[secret_code_confirmation]', :with => secret_code
end

When 'I fill in the secret code "$secret_code"' do |secret_code|
fill_in 'user[secret_code_confirmation]', :with => secret_code
end

When 'I fill in my secret code in all caps' do
fill_in 'user[secret_code_confirmation]', :with => secret_code.upcase
end
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/resque_steps.rb
Expand Up @@ -6,6 +6,10 @@
QUEUE.reset
end

When 'timed jobs are processed' do
QUEUE.run_timed_jobs(Time.now)
end

When /^jobs in (\d+) minutes from now are processed$/ do |min|
Timecop.freeze(Time.now + min.to_i.minutes)
QUEUE.run_timed_jobs(Time.now)
Expand Down
7 changes: 3 additions & 4 deletions features/support/fake_resque.rb
Expand Up @@ -21,10 +21,9 @@ def self.run_jobs
end

def self.run_timed_jobs(future_time)
while !self.delayed_queue.empty?
args = self.delayed_queue.pop
timestamp, klass, args = args.shift, args.shift, args.shift
if (future_time - timestamp) >= 0
self.delayed_queue.each do |timestamp, klass, args|
time_diff = future_time - timestamp
if time_diff < 1 && time_diff >= 0
klass.send(:perform, *JSON.parse(args))
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/factories.rb
Expand Up @@ -8,6 +8,10 @@
u.name "Jenny"
end

Factory.define :empty_user, :class => User do |user_factory|
user_factory.phone_number { Factory.next :phone_number }
end

Factory.define :young_person, :parent => :user do |u|
u.dob { 21.years.ago }
u.looking_for_minimum_age 20
Expand Down

0 comments on commit 444faaf

Please sign in to comment.