Browse files

matching algorithm select innovations closest to the day of the year,…

… not to the absolute date
  • Loading branch information...
1 parent b545138 commit eb9e55729a0a92c19835176e14b8ab4320489ef6 @dhruvbansal dhruvbansal committed Sep 5, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 innovation_matcher.rb
View
2 innovation_matcher.rb
@@ -17,7 +17,7 @@ def find_match user_data
dob = (user_data["dob"] or return)
[].tap do |innovations|
begin
- result_set = db.query("SELECT * FROM innovations ORDER BY ABS(innovation_date - DATE(\"#{Mysql.quote(dob)}\")) LIMIT 3")
+ result_set = db.query("SELECT * FROM innovations WHERE innovation_date != \"0000-00-00\" ORDER BY ABS(DAYOFYEAR(DATE(\"#{Mysql.quote(dob)}\")) - DAYOFYEAR(innovation_date)) LIMIT 3")
rescue Mysql::Error => e
return
end

0 comments on commit eb9e557

Please sign in to comment.