Giter Site home page Giter Site logo

bus2go / tavindo-load-data Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 10 KB

Gather data from different places to build a single database of the bus transport system from Rio de Janeiro

License: MIT License

JavaScript 98.09% Shell 1.91%
javascript bus rio-de-janeiro nodejs

tavindo-load-data's Introduction

tavindo-load-data

Gather data from different places to build a single database for the bus transport system from Rio de Janeiro.

General Info

It was developed using Node 7 and async/await, so be careful to set your environment correctly before installing dependencies and running the application. I recommend using NVM for node version management.

Configuration

All necessary configuration info is explicit on config.default.js. It should be updated to reflect your environment, renamed to config.js and put outside project. Currently it's pointing to your projects's parent folder. When you decide to relocate elsewhere, don't forget to update its references on db.js and index.js.

db: {
    user: 'user', // database user
    password: 'password', // database password
    host: 'localhost', // database host
    database: 'database' // database schema
},
itinerary: {
    url: '', // URL to the website where you gather the general info
    headers: [],
    body: '',
    routes: '' // URL to the website where you gather the routes of each bus line
}

Database

It was designed to work with PostgreSQL, but you can use any database you want. In that case, you'll probably need to change db.js.

Creating your database

Once you installed PostgreSQL, you will need to create your user and schema. If you are clueless on database configuration, all you need to do is execute the commands below:

$ sudo service postgresql restart # make sure PostgreSQL is running
$ createuser -d -P -s <user_name>
$ createdb -O <user_name> <database_name>

The first one will create your user, the second will create your schema. The user name and schema name must match whatever is on your config.js.

Once everything is set, run npm run create:db, so the necessary tables are created. This only needs to be done once, but has to be ran before anything else.

After creating the tables, you're good to go.

Running

Run npm start. It will get the info from config.js and it'll start to gather everything. But it will take a long time since there are around 3000 bus lines in the entire Rio de Janeiro metropolitan area. Because of that, it was designed to NOT run things in parallel, otherwise your queries could be perceived as an attack. It IS designed to run in sequence and it IS designed to be slow. Actually it should be even slower.

If you want to get data from a specific bus route, you can pass it as argument, just run

npm start -- --short_name=100

In this example, it will search for all bus lines that contains 100 on its short name.

License

MIT. See LICENSE file.

tavindo-load-data's People

Contributors

lalkmim avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.