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

Rework the earlier API and launch as a v0.1 effort #194

Closed
gbinal opened this issue Feb 9, 2017 · 4 comments
Closed

Rework the earlier API and launch as a v0.1 effort #194

gbinal opened this issue Feb 9, 2017 · 4 comments
Assignees

Comments

@gbinal
Copy link
Member

gbinal commented Feb 9, 2017

No description provided.

@jmhooper
Copy link
Member

#152 contains the original work for the API

@jmhooper
Copy link
Member

At this point, this is what I'm thinking:

We can add a flag to the command (similar to --publish) that tells the reporter to write the reports to a postgres db. The db will have one table for the data points described in the data array. Each entry element in the array will be an array in the table. I'm thinking something like this:

  • id
  • report_name: The name of the report the data is associated with
  • agency_name: The name of the agency the data is associated with. Null if gov-wide
  • date: The date associated with the data
  • data: jsonb column with the data point, minus the data prop if present
  • created_at
  • updated_at

For reports that are not realtime, we can check for a ga:date dimension. For each report with one, we can merge into the existing data for that report. This means that for each point we look up whether a record already exists. If it does, we update it. If it doesn't we insert it. I'm a bit concerned about performance here b/c some of the reports are long, but we can try it and see what happens.

Realtime reports are easier b/c we do not need to check for existing records. We can simply set the date to the current date and insert.

We can build an API app that ties into the same database. I'm a fan of allowing that app to manage the db schema b/c a web app framework will likely have better tooling for managing schema.

jmhooper added a commit that referenced this issue Feb 17, 2017
This commit adds a `write-to-db-module`. This module takes the result of fetching and processing a report, and adds the data to a postgres database. The plan is for the reporter to insert this data in such a way that another application can come in behind it and serve the data via an API.

To enable this feature, the reporter is run with the `--write-to-database` option. The reporter needs the database to be configured in the config under the `postgres` prop.

Ref #194
jmhooper added a commit that referenced this issue Feb 23, 2017
This command adds an option for specifying an agency in the CLI options. This allows the name of the agency the data is being pulled for to be included in the final report, and in the data that is written to the database.

Ref #194
jmhooper added a commit that referenced this issue Mar 2, 2017
This commit adds the agency name to the reports the analytics reporter produces. When #197 is merged, this will be used to write associate agencies with reports in our database.

The agency is specified by setting the `AGENCY_NAME` environment variable which is picked up by the config.

Ref #194
jmhooper added a commit that referenced this issue Mar 3, 2017
This commit adds a `write-to-db-module`. This module takes the result of fetching and processing a report, and adds the data to a postgres database. The plan is for the reporter to insert this data in such a way that another application can come in behind it and serve the data via an API.

To enable this feature, the reporter is run with the `--write-to-database` option. The reporter needs the database to be configured in the config under the `postgres` prop.

Ref #194
@gbinal
Copy link
Member Author

gbinal commented May 30, 2017

This is done.

@gbinal gbinal closed this as completed May 30, 2017
@gbinal
Copy link
Member Author

gbinal commented May 30, 2017

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

No branches or pull requests

2 participants