Skip to content

Axylos/AllIncomeFoods

 
 

Repository files navigation

License INFO: - Note, this license applies to all files within the ysiadf/AllIncomeFoods repo.
It is an OSI approved license.

Copyright [2011] [Ysiad Ferreiras, Aaron Bannert, Jeremy Canfield and Michelle Koeth]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

--------------

Introduction:

In order to get up and running with SnapFresh, you need to install postgreSQL and then seed the database. The instructions on how to do this are listed below.

---------------

Prototyping of extraction of backend data and some geocoding associated thereof for this project can be found on this scraperwiki:
http://scraperwiki.com/scrapers/allincomefoods/

----------
INSTALLING AND CONFIGURING POSTGRESQL:

There's many ways you can install postgres locally, but if you're on a Mac, one way that's pretty easy is to download the installer here: http://www.enterprisedb.com/products-services-training/pgdownload#osx (current version as of July 1, 2011 is Version 9.0.4-1, and this is a compatible version with our app).

Once its installed, you need to create the user and install the gem.
If you're running Mac OSX, you'll need to put pg_config in your path, or you'll get an error upon trying to install the pg
gem. Do this by running this command at the prompt (instead of the above "sudo gem install pg" command, and assuming you've installed postgresql 9.0):

- If you have installed a different version of PostgreSQL (for ex. 9.1), then set the path statement below accordingly

$ PATH=$PATH:/Library/PostgreSQL/9.0/bin sudo gem install pg

$ sudo -u postgres createuser -P aif
  # password is aif123
(not superuser, yes can create DBs, no can't create roles)

Now you're ready to install the gem bundle, at the command line enter:
bundle install

Now you're ready to start the server:
You can use the pgAdmin tool to start up the server, located under /Library/PostgreSQL/9.0/. Remember the password you create for the postgres user.

FYI: Anytime you do a bundle install, and you're installing the pg gem over again (coz say your HD crashes, or any 
numerous annoying things that require you to rebuild your development environment) if you don't have the PATH set up ahead of time, you will get failure upon trying
to install the pg gem. So be sure to always do the PATH if you need to reinstall the gem.

********************

FOR LINUX OR MAC PEOPLE WHO ARE COMMAND LINE WIZARDS:
Install postgres locally how ever you like, start up
the server, and create the right users:

$ sudo yum install postgresql-server postgresql-client postgresql-docs postgresql-devel
$ sudo gem install pg
$ bundle install
$ sudo service postgresql start

Note that postgresql-devel is required (on whatever platform you're on)
since the headers and pg_config are required to build the dependent GEMs.

$ sudo -u postgres createuser -P aif
  # password is aif123
(not superuser, yes can create DBs, no can't create roles)

_____________________________________________________________________________
TO CREATE DATABASE AND SEED DATA:

Inside of `config/`, locate `database.yml.example` and rename it too `database.yml`. You may have to change the examples to your personal configurations.

$ rake db:create:all

-- If you are using Ruby 1.9.2 and run into a segmentation fault error upon running the rake command (due to the
nokogiri gem) run this first: gem pristine nokogiri
Then rerun the rake command. 

$ rake db:schema:load

Now the database is created, and next you will seed the data, so be sure that you are in the db directory before
you run this:

$ rake db:seed

--- ALTERNATE way to load the full data (if above steps dont work for some reason):

1) Run "ruby db/cronjob.rb" to fetch all data files, unzip and then produce
a single CSV file called "all.csv".

2) Bulk-load into postgres, using this command:
grep -v '"NULL"' all.csv | psql allincomefoods_dev -c "copy retailers (name, lon, lat, street, city, state, zip, zip_plus_four) from stdin null as 'NULL' csv;"

3) (Optional) Remove all the .zip and .csv files that were created as part
of the download process.


\/\/00T! You should be all installed and stuff now. 
-----------------------------------

REFRESHING DATA: (New as of 12/3/2012)

from command line, and within the lib/tasks dir, type:

>rake db:datarefresh

A line should print out every 10K rows that are refreshed - this way you can check on the progress of the script which
takes at least 10 min to run.

About

An app that lists places that accept food stamps

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors