GithubHelp home page GithubHelp logo

map-collector-cli's Introduction

Map Collector Command Line Interface

This project is for TIP Strategies. It pulls recent data from BLS for their map web visualization.

Usage

Running the Application

npm run datapull -- --year 2019
npm run export

Adding a city

Prerequisite: Have sqlite interface set up on your local machine

in your sqlite terminal:

INSERT INTO cities (id, lat, lon, name) VALUES ('234540000092', '123', '456', 'Example City, TN');

Note: the id value should be stripped of its 3-character non-numeric prefix. We add those on request to get relevant data from BLS. You will need to find the latitude and longitude from another service.

Sharing data with someone else to run the program

git add .
git commit -m "feat: Add data for <this month> <this year>"
git push origin master

Testing the Application

npm run test

Administration

Version Update

We are currently handling updates only through git versioning.

To update to the lastest:

git checkout master
git fetch
git reset --hard origin/master

API Keys

We use Version 2.0 of the BLS API. The Bureau of Labor Statistics expires keys on an annual basis. This will require re-registering for new keys every year. When the time comes, refer to the documented keys in your secrets/bls-keys.json file and edit all or some of the keys as desired.

If collaborating with another person, communicate the change as needed.

Link to the BLS Registration engine can be found here.

File structure for adding your own keys:

{
  "keys": [
    {
      "name": "[email protected]",
      "key": "abcxxxxxxxxxxxxxxxxxxxxxxxxxx123"
    },
    {
      "name": "[email protected]",
      "key": "abcxxxxxxxxxxxxxxxxxxxxxxxxxx123"
    },
    {
      "name": "[email protected]",
      "key": "abcxxxxxxxxxxxxxxxxxxxxxxxxxx123"
    },
    {
      "name": "[email protected]",
      "key": "abcxxxxxxxxxxxxxxxxxxxxxxxxxx123"
    },
    {
      "name": "[email protected]",
      "key": "abcxxxxxxxxxxxxxxxxxxxxxxxxxx123"
    }
  ],
  "index": 0
}

Development

Prerequisites

  • Node v8 (installation recommended through nvm)
  • npm
  • git

Getting Started

npm install

This program will depend on some secrets. Get those from an available party and store in secrets/bls-keys.json.

Troubleshooting the data stored locally

sqlite3 data/bls.db

.tables
SELECT * FROM <table> WHERE period LIKE "2019%"
SELECT * FROM <table> WHERE city_id="<some-id>"
.exit

Running Migrations

Nothing is instrumented right now, however for the migration process from a previous iteration of this application we retained a way to programmatically migrate old data. Take a look in the data/migrations folder for some optional migration behavior.

Tools

Architectural choices are as follows:

  • User Interface: CLI with the assistance of yargs library
  • Data Storage: SQLite
  • Data Request: HTTP API Rest endpoints in Node.js from BLS
  • Data Reading: Exporting as CSV on disk where program is executed. File location is printed on save.

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.