Permalink
Browse files

.

  • Loading branch information...
1 parent 5459ed7 commit 73dc1d78a1ee67af3b5478ed7c90ca0b806dcd48 Dhruv Bansal committed Aug 29, 2012
Showing with 29 additions and 13 deletions.
  1. +2 −2 Gemfile.lock
  2. +9 −0 README.rdoc
  3. 0 config.ru
  4. +18 −11 innovation_matcher.rb
View
@@ -9,9 +9,9 @@ GEM
rack
raindrops (0.10.0)
sinatra (1.3.3)
- rack (~> 1.3, >= 1.3.6)
+ rack (>= 1.3.6, ~> 1.3)
rack-protection (~> 1.2)
- tilt (~> 1.3, >= 1.3.3)
+ tilt (>= 1.3.3, ~> 1.3)
tilt (1.3.3)
unicorn (4.3.1)
kgio (~> 2.6)
View
@@ -0,0 +1,9 @@
+= Installation & Running
+
+ git clone https://github.com/infochimps/chiat_day_innovation_matcher.git
+ cd chiat_day_innovation_matcher
+ bundle install
+ RACK_ENV=development ruby innovation_matcher.rb
+
+
+
View
No changes.
View
@@ -5,16 +5,26 @@
set :show_exceptions, false
+def db
+ @db ||= Mysql.connect(ENV["MYSQL_HOST"], ENV["MYSQL_USER"], ENV["MYSQL_PASSWORD"], ENV["MYSQL_DATABASE"])
+end
+
def find_match dob
- { "id" => 11, "innovation" => "motion picture projector", "innovator" => "Fred H. Meyer",
- "date" => Time.parse("1972-09-04"), "patent_number" => "US3642357",
- "link_to_patent" => "http://www.google.com/patents/US3642357",
- "notes" => "This motion picture viewer projected movies onto a screen by cycling the film forward or backward at a set speed."
- }
+ # { "id" => 11, "innovation" => "motion picture projector", "innovator" => "Fred H. Meyer",
+ # "date" => Time.parse("1972-09-04"), "patent_number" => "US3642357",
+ # "link_to_patent" => "http://www.google.com/patents/US3642357",
+ # "notes" => "This motion picture viewer projected movies onto a screen by cycling the film forward or backward at a set speed."
+ # }
+ db.query("SELECT * FROM innovations LIMIT 3")
+end
+
+def save_match user_data, innovations
+ innovations
+ # {"id" => 123}.merge("innovation" => innovation, "user_data" => user_data)
end
-def save_match user_data, innovation
- {"id" => 123}.merge("innovation" => innovation, "user_data" => user_data)
+def retrieve_match id
+ db.query("SELECT * FROM matches WHERE match_id=#{id.to_i}")
end
def pretty_json obj
@@ -39,10 +49,7 @@ def pretty_json obj
end
get "/matches/:id" do
- pretty_json({"id" => 123}.merge("innovation" => find_match({})))
-end
-
-get "/innovations/:id" do
+ pretty_json(retrieve_match(request.params[:id]))
end
error 400 do

0 comments on commit 73dc1d7

Please sign in to comment.