Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Motivate people who have never filled out their profile

  • Loading branch information...
commit 444faaf0760a0f134ced197180d0b40d33c57d1f 1 parent ba6f44e
@mike-burns mike-burns authored
View
2  TODO
@@ -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
View
9 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
@@ -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
View
13 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
View
10 app/models/user.rb
@@ -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
@@ -117,6 +117,10 @@ def tell(msg)
Message.deliver(self.phone_number, msg)
end
+ def incomplete?
+ dob.nil?
+ end
+
protected
def normalize_phone_number
@@ -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
View
46 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
View
4 features/step_definitions/form_steps.rb
@@ -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
View
4 features/step_definitions/resque_steps.rb
@@ -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)
View
7 features/support/fake_resque.rb
@@ -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
View
4 spec/factories.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.