Permalink
Browse files

Let users skeeze

  • Loading branch information...
1 parent 8928aa7 commit 7fe4951d8bb94e9e2ae508c4de402c8b720c98ef Emma Lindsay committed Nov 14, 2010
Showing with 100 additions and 36 deletions.
  1. +44 −34 Gemfile.lock
  2. +22 −2 app/models/message.rb
  3. +17 −0 app/models/user.rb
  4. +1 −0 config/initializers/commands.rb
  5. +16 −0 features/the_app.feature
View
@@ -43,27 +43,30 @@ GEM
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.0.0)
- capybara (0.3.9)
+ capybara (0.4.0)
+ celerity (>= 0.7.9)
culerity (>= 0.2.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
- selenium-webdriver (>= 0.0.3)
+ selenium-webdriver (>= 0.0.27)
+ xpath (~> 0.1.2)
+ celerity (0.8.4)
childprocess (0.0.9)
ffi (~> 0.6.3)
- columnize (0.3.1)
+ columnize (0.3.2)
configuration (1.1.0)
- cucumber (0.9.2)
+ cucumber (0.9.4)
builder (~> 2.1.2)
diff-lcs (~> 1.1.2)
- gherkin (~> 2.2.5)
+ gherkin (~> 2.2.9)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
cucumber-rails (0.3.2)
cucumber (>= 0.8.0)
culerity (0.2.12)
- database_cleaner (0.5.2)
+ database_cleaner (0.6.0)
diff-lcs (1.1.2)
dynamic_form (1.1.3)
erubis (2.6.6)
@@ -75,31 +78,33 @@ GEM
fakeweb (1.3.0)
ffi (0.6.3)
rake (>= 0.8.7)
- flutie (1.0.4)
+ flutie (1.1.2)
formtastic (1.1.0)
actionpack (>= 2.3.0)
activesupport (>= 2.3.0)
i18n (>= 0.4.0)
gherkin (2.2.9)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
- haml (3.0.21)
+ haml (3.0.23)
hashie (0.4.0)
- high_voltage (0.9.1)
+ high_voltage (0.9.2)
highline (1.6.1)
- hoptoad_notifier (2.3.8)
+ hoptoad_notifier (2.3.12)
activesupport
- i18n (0.4.1)
+ builder
+ i18n (0.4.2)
json (1.4.6)
json_pure (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
linecache (0.43)
- mail (2.2.7)
+ mail (2.2.9)
activesupport (>= 2.3.6)
- mime-types
- treetop (>= 1.4.5)
+ i18n (~> 0.4.1)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
mime-types (1.16)
mocha (0.9.8)
rake
@@ -112,7 +117,7 @@ GEM
net-ssh-gateway (1.0.1)
net-ssh (>= 1.99.1)
nokogiri (1.4.3.1)
- paperclip (2.3.4)
+ paperclip (2.3.5)
activerecord
activesupport
polyglot (0.3.1)
@@ -135,7 +140,7 @@ GEM
rake (>= 0.8.4)
thor (~> 0.14.0)
rake (0.8.7)
- redis (2.0.11)
+ redis (2.1.1)
redis-namespace (0.8.0)
redis (< 3.0.0)
relevance-rcov (0.9.2.1)
@@ -144,42 +149,45 @@ GEM
redis-namespace (~> 0.8.0)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
- resque-restriction (0.2.2)
+ resque-restriction (0.3.0)
resque (>= 1.7.0)
- resque-scheduler (1.9.6)
+ resque-scheduler (1.9.7)
redis (>= 2.0.1)
resque (>= 1.8.0)
rufus-scheduler
- rspec (2.0.0)
- rspec-core (= 2.0.0)
- rspec-expectations (= 2.0.0)
- rspec-mocks (= 2.0.0)
- rspec-core (2.0.0)
- rspec-expectations (2.0.0)
+ rspec (2.0.1)
+ rspec-core (~> 2.0.1)
+ rspec-expectations (~> 2.0.1)
+ rspec-mocks (~> 2.0.1)
+ rspec-core (2.0.1)
+ rspec-expectations (2.0.1)
diff-lcs (>= 1.1.2)
- rspec-mocks (2.0.0)
- rspec-core (= 2.0.0)
- rspec-expectations (= 2.0.0)
+ rspec-mocks (2.0.1)
+ rspec-core (~> 2.0.1)
+ rspec-expectations (~> 2.0.1)
rspec-rails (2.0.1)
rspec (~> 2.0.0)
- ruby-debug (0.10.3)
+ ruby-debug (0.10.4)
columnize (>= 0.1)
- ruby-debug-base (~> 0.10.3.0)
- ruby-debug-base (0.10.3)
+ ruby-debug-base (~> 0.10.4.0)
+ ruby-debug-base (0.10.4)
linecache (>= 0.3)
rubyzip (0.9.4)
- rufus-scheduler (2.0.6)
+ rufus-scheduler (2.0.7)
+ tzinfo
selenium-webdriver (0.0.29)
childprocess (>= 0.0.7)
ffi (~> 0.6.3)
json_pure
rubyzip
sham_rack (1.3.2)
shoulda (2.11.3)
- sinatra (1.0)
- rack (>= 1.0)
+ sinatra (1.1.0)
+ rack (~> 1.1)
+ tilt (~> 1.1)
term-ansicolor (1.0.5)
- thor (0.14.3)
+ thor (0.14.4)
+ tilt (1.1)
timecop (0.3.5)
treetop (1.4.8)
polyglot (>= 0.3.1)
@@ -190,6 +198,8 @@ GEM
vegas (0.1.8)
rack (>= 1.0.0)
will_paginate (2.3.15)
+ xpath (0.1.2)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
View
@@ -74,6 +74,8 @@ def self.handle_incoming(phone_number, message_text)
handle_new_date(user)
elsif message_text =~ /^\s*#{COMMANDS[:ok].gsub(' ','.*')}/i
handle_ok(user)
+ elsif message_text =~ /^\s*#{COMMANDS[:skeeze].gsub(' ','.*')}/i
+ handle_ok(user, :skeeze => true)
elsif message_text =~ /^\s*#{COMMANDS[:accept].gsub(' ','.*')}/i
handle_accept(user)
elsif message_text =~ /^\s*#{COMMANDS[:sext].gsub(' ','.*')}\s*(.*)/i
@@ -154,11 +156,29 @@ def self.outside_dating_hours(user)
user.tell("Outside of the dating hours: #{DATING_START_STRING} to #{DATING_END_STRING}. Please try again then!")
end
- def self.handle_ok(user)
+ def self.handle_ok(user, meetup_restrictions = {})
meetup = user.founded_meetups.proposed.first
if meetup
meetup.unschedule!
- user.matching_for_meetup(meetup).first(5).each do |matching_user|
+ if meetup_restrictions[:skeeze]
+ matches = user.skeeze_matching_for_meetup(meetup).first(5)
+ else
+ matches = user.matching_for_meetup(meetup).first(5)
+ end
+ matches.each do |matching_user|
+ Offer.create(:offered_user => matching_user, :meetup => meetup)
+ end
+ QUEUE.enqueue_at(5.minutes.from_now, RejectMessageDelayer, :user_id => user.id)
+ else
+ handle_unknown(user)
+ end
+ end
+
+ def self.handle_skeeze(user)
+ meetup = user.founded_meetups.proposed.first
+ if meetup
+ meetup.unschedule!
+ user.skeeze_matching_for_meetup(meetup).first(5).each do |matching_user|
Offer.create(:offered_user => matching_user, :meetup => meetup)
end
QUEUE.enqueue_at(5.minutes.from_now, RejectMessageDelayer, :user_id => user.id)
View
@@ -43,6 +43,12 @@ def self.looking_for(user)
user.male, user.female, user.other, user.age_in_years, user.age_in_years)
end
+ def self.looking_for_sort_of_like(user)
+ where('(users.looking_for_male = ? OR users.looking_for_female = ? OR users.looking_for_other = ?) AND ? >= users.looking_for_minimum_age AND ? <= users.looking_for_maximum_age',
+ user.male, user.female, user.other, user.age_in_years + 2, user.age_in_years - 2)
+
+ end
+
def self.men
where('users.male')
end
@@ -107,6 +113,17 @@ def matching_for_meetup(meetup)
sort_by_least_offered
end
+ def skeeze_matching_for_meetup(meetup)
+ User.
+ within_age_range(self.looking_for_minimum_age, self.looking_for_maximum_age).
+ looking_for_sort_of_like(self).
+ without_offers.
+ without_founded_meetups_in_progress.
+ looking_for_gender(meetup)#.
+ # exclude(self).
+ # sort_by_least_offered
+ end
+
def deliver_secret_code
self.tell(
"Before you can become an instalover you must know this secret code: '#{self.secret_code}'. " +
@@ -1,6 +1,7 @@
COMMANDS = {
:new_date => 'new date',
:ok => 'ok',
+ :skeeze => 'skeeze',
:accept => 'accept',
:sext => 'say',
:quit => 'safeword',
@@ -233,3 +233,19 @@ Feature: The whole app
Then "16171231234" should get a text "Want to go on a date with Emma at Silvertone at 09:00PM? Reply 'accept' or ignore."
And "16176060842" should get a text "Want to go on a date with Emma at Silvertone at 09:00PM? Reply 'accept' or ignore."
And "11111111111" should get a text "Want to go on a date with Emma at Silvertone at 09:00PM? Reply 'accept' or ignore."
+
+ Scenario: User skeezes to increase the matches they can get
+ Given the following users exist:
+ | Phone Number | Male | Female | Other | Looking For Male | Looking For Female | Looking For Other | Dob | Looking For Minimum Age | Looking For Maximum Age | Name |
+ | 16669996669 | false | true | false | true | true | true | 09/08/1984 | 18 | 30 | Emma |
+ | 19991119991 | false | true | false | false | true | false | 11/06/1990 | 18 | 30 | Tatu |
+ When "16669996669" texts instalover with "woman"
+ Then "16669996669" should get a text whose message includes "Should we find you a date"
+ When "16669996669" texts instalover with "OK"
+ Then "19991119991" should get a text whose message includes "Want to go on a date with Emma"
+ When jobs in 5 minutes from now are processed
+ Then "16669996669" should get a text whose message includes "every number in our little black book"
+ When "16669996669" texts instalover with "woman"
+ Then "16669996669" should get a text whose message includes "Should we find you a date"
+ When "16669996669" texts instalover with "skeeze"
+ Then "19991119991" should get a text whose message includes "Want to go on a date with Emma"

0 comments on commit 7fe4951

Please sign in to comment.