auto complete documentation - 401ChemistryGenealogy/ChemistryGenealogy GitHub Wiki

The /auto_complete route accepts a query string with a name parameter and returns a LIKE query on the people table along with the relevant institutions.

example

curl -X GET "localhost:3000/auto_complete?name="

{  
   "people":[  
      {  
         "id":1,
         "name":"todd lowary",
         "position":"professor",
         "institution_id":1
      },
      {  
         "id":2,
         "name":"wei shi",
         "position":"assistant professor",
         "institution_id":3
      },
      {  
         "id":3,
         "name":"ole hindsgaul",
         "position":"professor emeritus",
         "institution_id":1
      },
      {  
         "id":4,
         "name":"david bundle",
         "position":"professor emeritus",
         "institution_id":1
      },
      {  
         "id":5,
         "name":"moreten meldel",
         "position":null,
         "institution_id":null
      },
      {  
         "id":6,
         "name":"raymond lemieux",
         "position":null,
         "institution_id":null
      },
      {  
         "id":7,
         "name":"james baddiley",
         "position":null,
         "institution_id":null
      },
      {  
         "id":8,
         "name":"jun liu",
         "position":null,
         "institution_id":null
      },
      {  
         "id":9,
         "name":"clinton ballou",
         "position":null,
         "institution_id":null
      },
      {  
         "id":10,
         "name":"harold jennings",
         "position":null,
         "institution_id":null
      }
   ],
   "institutions":[  
      {  
         "id":1,
         "name":"university of alberta"
      },
      {  
         "id":3,
         "name":"university of arkansas"
      }
   ]
}

As you can see, leaving a blank name parameter matches against everything in the database. An example using a non-blank querystring

curl -X GET "localhost:3000/auto_complete?name=to"
{  
   "people":[  
      {  
         "id":1,
         "name":"todd lowary",
         "position":"professor",
         "institution_id":1
      },
      {  
         "id":9,
         "name":"clinton ballou",
         "position":null,
         "institution_id":null
      }
   ],
   "institutions":[  
      {  
         "id":1,
         "name":"university of alberta"
      }
   ]
}

We can also autocomplete institutions:

curl -X GET "localhost:3000/auto_complete?institution="

{  
   "institutions":[  
      {  
         "id":1,
         "name":"university of alberta"
      },
      {  
         "id":2,
         "name":"carlsberg laboratory"
      },
      {  
         "id":3,
         "name":"university of arkansas"
      },
      {  
         "id":4,
         "name":"johns hopkins university"
      },
      {  
         "id":5,
         "name":"university of california, berkeley"
      },
      {  
         "id":6,
         "name":"nottingham university"
      },
      {  
         "id":7,
         "name":"national research council of canada"
      }
   ]
}

curl -X GET "localhost:3000/auto_complete?institution=un"

{  
   "institutions":[  
      {  
         "id":1,
         "name":"university of alberta"
      },
      {  
         "id":3,
         "name":"university of arkansas"
      },
      {  
         "id":4,
         "name":"johns hopkins university"
      },
      {  
         "id":5,
         "name":"university of california, berkeley"
      },
      {  
         "id":6,
         "name":"nottingham university"
      },
      {  
         "id":7,
         "name":"national research council of canada"
      }
   ]
}

code

class

class tests

controller

controller tests