Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report api prototype #152

Closed
wants to merge 17 commits into from
Closed

Report api prototype #152

wants to merge 17 commits into from

Conversation

cacraig
Copy link

@cacraig cacraig commented Apr 18, 2016

Requirements for deployment:

  • Add environment variables to all *.env files:
export DB_DRIVER=[mongodb,rethinkdb]
export TABLE_NAME=[epa,ed,nasa, ...]
export DB_HOST=
export DB_PORT=
export DB_NAME=
export DB_USERNAME=
export DB_PASSWORD=

RethinkDB

  • Install RethinkDB >2.0.0
  • run npm install

OR

MongoDB

  • Install MongoDB > 3.0.0
  • run npm install

Usage:

https://<ANALYTICS_URL>/api/v1.0/:agency/:report?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
example:
https://www.analytics.usa.gov/api/v1.0/epa/devices?start_date=2016-01-27&end_date=2016-01-28

result

[
  {
    "date": "2016-01-28T00:00:00.000Z",
    "device": "desktop",
    "visits": "144"
  },
  {
    "date": "2016-01-28T00:00:00.000Z",
    "device": "mobile",
    "visits": "26"
  },
  {
    "date": "2016-01-28T00:00:00.000Z",
    "device": "tablet",
    "visits": "4"
  }, ... ]

Notes:

  • Stores time series data for all reports with the "ga:date" dimension. Merges results, so it will be a continuous dataset.
  • All other reports are stored as-is, and replaced when updated.

todo:

  • Accept limit, order, and sort parameters.
  • Add response codes. 500, 400, 403(?Add API keys?), 200.
  • Add more agencies -> Add ability to get sub-agency level data.

@konklone
Copy link
Contributor

One major thing I'd like to see here is the DB-level work moved into its own file. Right now, there's a lot of direct DB access going on in both bin/analytics and analytics.js. Those files would ideally remain nearly untouched by this addition, and nearly all of the API-specific code would be in its own file/module.

@cacraig
Copy link
Author

cacraig commented Apr 28, 2016

@konklone Good point, I'll encapsulate the DB work within it's own module.

@cacraig
Copy link
Author

cacraig commented May 1, 2016

@konklone - I made the following changes:

(1) Moved DB stuff off to it's own module,
(2) Deferred loading of this module to ensure DB config info is defined for the environment.

Assuming everything is 👍 , how do you think should we go about deploying this? As I mentioned ^^^ I'm going to need to install Rethinkdb, and add environment vars on prod/test environments.

@konklone
Copy link
Contributor

konklone commented May 2, 2016

@cacraig Let's take it to Slack so we can talk through 18F-specific operations and deployment issues. Not that it's sensitive, it's just not pertinent to other repo watchers.

@cacraig
Copy link
Author

cacraig commented May 2, 2016

@konklone I added a MongoDB driver for this API, and made it a bit more generic. Thanks for all the feedback thusfar! We can continue on the deployment stuff on slack.

@cacraig cacraig changed the title Report api proto - Do not merge! Report api prototype May 3, 2016
@konklone konklone closed this Oct 30, 2016
@konklone konklone deleted the report-api-proto branch October 30, 2016 23:39
@konklone konklone restored the report-api-proto branch October 30, 2016 23:39
@konklone konklone deleted the report-api-proto branch June 17, 2017 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants