Batch Insert Workshop
To start your project:
- Install dependencies with
mix deps.get
- Create and migrate your database with
mix ecto.create && mix ecto.migrate
- Optional: Install Node.js dependencies with
cd assets && npm install
- Optional: Set up Github API Token: https://developer.github.com/v4/guides/forming-calls/#authenticating-with-graphql
- Copy .env_sample to .env; put the API token in the ENV var; run
source .env
- Start Iex:
iex -S mix
Instructions
- Retrieve Unique Languages from JSON Payload.
- Insert all Unique Languages in one query, returning values (hint: Repo.insert_all with on_conflict & returning clause)
- Insert all Repos, and return all values from the Insert.
- Loop back through the payload, mapping the IDs returned from Languages and Repos (Steps 2 & 3)
- Insert these into the repo_languages table.
- Write tests
Where to begin:
- If you have a Github API Token set up (from Start your project section): You can run
GithubApi.repos
to fetch the first 10 repos. The file is located at lib/batch_insert_workshop/services/github_api.ex`
OR
- If you don't have a token set up, you can get a sample payload from:
GithubPayload.sample
Tables to use for Part 1
- Languages
- Repos
- Repo Languages
Located at: batch_insert_workshop/model/