From 94f20ba684ce534411f72a32ebc5b0ad6bba8eca Mon Sep 17 00:00:00 2001 From: rmaskey Date: Sun, 10 Oct 2010 08:43:43 -0700 Subject: [PATCH 1/4] resolution for issue #151 - search with multiple words --- app/models/person.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 76bcd2aa3..445b1bba9 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -34,8 +34,23 @@ class Person /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix def self.search(query) - query = Regexp.escape( query.to_s.strip ) - Person.all('profile.first_name' => /^#{query}/i) | Person.all('profile.last_name' => /^#{query}/i) + qTokens = query.to_s.strip.split(" ") + fullQueryText = Regexp.escape( query.to_s.strip ) + + p = Person.all('profile.first_name' => /^#{fullQueryText}/i) \ + | Person.all('profile.last_name' => /^#{fullQueryText}/i) + + qTokens.each { + |token| + + q = Regexp.escape( token.to_s.strip ) + p = Person.all('profile.first_name' => /^#{q}/i) \ + | Person.all('profile.last_name' => /^#{q}/i) \ + | p + + } + + return p end def real_name From 73e4d2b25b26d6380da4814ba8217fb717099b89 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 11 Oct 2010 11:08:54 -0700 Subject: [PATCH 2/4] Pull in search improvement, remove cruft --- app/models/person.rb | 4 +--- spec/models/person_spec.rb | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 1e358d11b..c2485d40d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -36,10 +36,8 @@ class Person def self.search(query) qTokens = query.to_s.strip.split(" ") fullQueryText = Regexp.escape( query.to_s.strip ) + p = [] - p = Person.all('profile.first_name' => /^#{fullQueryText}/i) \ - | Person.all('profile.last_name' => /^#{fullQueryText}/i) - qTokens.each { |token| diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index da535bfe3..b8738f934 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -160,7 +160,6 @@ describe Person do end it 'should yield results on full names' do - pending "Not yet implemented." people = Person.search("Casey Grippi") people.should == [@friend_four] end From 82e6e29e37e4852f66b8a0144aec7d37ad8c9891 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 11 Oct 2010 11:22:26 -0700 Subject: [PATCH 3/4] A small readme change --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fc4b5aedf..fa1cdd8fe 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,15 @@ instructions. You are welcome to contribute, add to and extend Diaspora however you see fit. We will do our best to incorporate everything that meets our guidelines. -Please make your changes on a topic branch in your repo and submit your pull request -from there, so that commits you don't want to submit aren't included. +You can find an introduction to the source code [here](http://github.com/diaspora/diaspora/wiki/An-Introduction-to-the-Diaspora-Source). + +Make a topic branch. By making your changes in a topic branch, you ensure that new commits to your master are not included in the pull request, and it's easier for us to merge your commits. Please do not rebase our tree into yours. See [here](http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html) for when to rebase. -All commits must be tested, and all your tests should be green +Patches must be tested, and all your tests should be green before a pull request is sent. Please write your tests in Rspec. GEMS: We would like to keep external dependencies unduplicated. We're using From 80d7a755b8f76b39b8b8513d81b4fa7dcc1bb97d Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 11 Oct 2010 11:27:10 -0700 Subject: [PATCH 4/4] Add links to issue tracker --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fa1cdd8fe..40447939b 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,14 @@ Initial installation instructions are [here](http://github.com/diaspora/diaspora We are continuing to build features and improve the code base. When we think it is ready for general use, we will post more final -instructions. +instructions. Issue tracking is at [bugs.joindiaspora.com](bugs.joindiaspora.com). ## Commit Guidelines You are welcome to contribute, add to and extend Diaspora however you see fit. We will do our best to incorporate everything that meets our guidelines. -You can find an introduction to the source code [here](http://github.com/diaspora/diaspora/wiki/An-Introduction-to-the-Diaspora-Source). +You can find an introduction to the source code [here](http://github.com/diaspora/diaspora/wiki/An-Introduction-to-the-Diaspora-Source). For an idea of where to start, look at our [issue tracker](bugs.joindiaspora.com). Make a topic branch. By making your changes in a topic branch, you ensure that new commits to your master are not included in the pull request, and it's easier for us to merge your commits.