Skip to content

Commit 75d2588

Browse files
Xavier MetichecchiaXavier Metichecchia
authored andcommitted
Merge branch 'develop' of https://github.com/18F/analytics-reporter-api into develop
2 parents 0405b45 + 6ad91c2 commit 75d2588

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@
55
# Analytics API
66

77
A system for publishing data retrieved from the Google Analytics API by the
8-
[Analytics Reporter](https://github.com/18F/analytics-reporter). The analytics
9-
API serves data written to a Progress database by the Analytics Reporter in
10-
response to HTTP requests.
8+
[Analytics Reporter](https://github.com/18F/analytics-reporter).
9+
This Analytics API serves data written to a PostgreSQL database by the Analytics Reporter,
10+
in response to HTTP requests.
1111

1212
# Setup
1313

14-
The Analytics API maintains the schema for the database that the Analytics
15-
Reporter writes to. Because of this, the Analytics API must be setup and
14+
This Analytics API maintains the schema for the database that the
15+
[Analytics Reporter](https://github.com/18F/analytics-reporter)
16+
writes to.
17+
Thus, the Analytics API must be setup and
1618
configured before the Analytics Reporter starts writing data.
1719

18-
First, the database needs to be created:
20+
First, create the database:
1921

2022
```shell
2123
createdb analytics-reporter
2224
```
2325

24-
Once the database is created, the app can be cloned and the dependencies can be
25-
installed via NPM. The install script has a postinstall hook that will migrate
26+
Once the database is created, clone the app and install the dependencies via NPM.
27+
The install script has a postinstall hook that will migrate
2628
the database.
2729

2830
```shell
@@ -31,17 +33,17 @@ cd analytics-reporter-api
3133
npm install
3234
```
3335

34-
Once all of the dependencies are installed, the app can be started.
36+
Once the dependencies are installed, the app can be started.
3537

3638
```shell
3739
npm start
3840
```
3941

40-
The API is not available at `http://localhost:4444/`
42+
The API should now be available at `http://localhost:4444/`
4143

42-
Note that the API will not render any data until Analytics Reporter is
43-
configured to write to the same database and run with the `--write-to-database`
44-
option.
44+
Note that the API will not render any data until
45+
[Analytics Reporter](https://github.com/18F/analytics-reporter)
46+
is configured to write to the same database and run with the `--write-to-database` option.
4547

4648
# Using the API
4749

@@ -106,14 +108,21 @@ If you need to migrate the database, you can create a new migration via `knex`,
106108
See [knex documentation](https://knexjs.org/#Installation-migrations) for more details.
107109

108110
# Running database migrations
111+
109112
## Locally
113+
110114
`npm run migrate`
115+
111116
## In production
117+
112118
In production, you can run database migrations via `cf run-task`. As with anything in production, be careful when doing this! First, try checking the current status of migrations using the `migrate:status` command
119+
113120
```
114121
cf run-task analytics-reporter-api --command "knex migrate:status" --name check_migration_status
115122
```
123+
116124
This will kick off a task - you can see the output by running:
125+
117126
```
118127
cf logs analytics-reporter-api --recent
119128
# the output will look something like...
@@ -127,6 +136,7 @@ cf logs analytics-reporter-api --recent
127136
```
128137

129138
To actually run the migration, you would run:
139+
130140
```
131141
cf run-task analytics-reporter-api --command "knex migrate:latest" --name run_db_migrations
132142
```

0 commit comments

Comments
 (0)