A web app for graphing alcohol unit intake documented via Google calendar events. Year, month, week and day views are available.
Note: Above is mocked data.- Deployed to Google Cloud Run (serverless) and scales to zero.
- File server for serving static web app files.
- Endpoint for scraping alcohol unit data from calendar events via the Google Calendar API; this unit data is then stored in InfluxDB. This endpoint is executed on a fixed interval via Cloud Scheduler.
curl -i -XPOST "localhost:8080/api/v1/collect" -d '{}'
curl -i -XPOST "localhost:8080/api/v1/collect" -d '{"start_time_override": "2009-11-10T23:00:00Z"}'
- Endpoint for querying alcohol unit consumption data stored in InfluxDB. Supported aggregations are
year
,month
,week
andday
.
curl -i -XGET "localhost:8080/api/v1/query?aggregation=week&end_time=2022-08-25T21:42:09Z"
curl -i -XGET "localhost:8080/api/v1/query?aggregation=day&start_time=2022-08-10T21:42:09Z&end_time=2022-08-25T21:42:09Z"
- Create a Service Account (SA) for your project
- Invite the SA email address to your calendar
- Create a key for the Service Account associated with your calendar; download the credentials key file
- Accept the invite for your SA with the
cmd/insert/main.go
script, passing in your calendar's ID:
go run main.go --calendar-id "abcdefghijklmop123456789@group.calendar.google.com" --creds-file ./credentials.json
2022/06/22 00:53:52 successfully inserted
- Ensure the credentials key file downloaded in the setup stage resides as
./config/credentials.json
- Run with
go run main.go --local
- Navigate to
http://localhost:8080
make deploy
A demo version of the app with mocked data for all available views (navigate to http://localhost:8080
).
cd cmd/demo
go run main.go
# Navigate to http://localhost:8080