chore: use config for api key dummy

This commit is contained in:
Zach Daniel 2023-10-01 13:46:20 -04:00
parent 33467d034f
commit b935c289d2
2 changed files with 10 additions and 1 deletions

View file

@ -16,6 +16,7 @@ config :open_ai,
api_key: System.get_env("OPEN_API_API_KEY")
config :ash_hq, :github,
api_key: System.get_env("GITHUB_API_KEY"),
client_id: System.get_env("GITHUB_CLIENT_ID"),
client_secret: System.get_env("GITHUB_CLIENT_SECRET"),
redirect_uri: System.get_env("GITHUB_REDIRECT_URI")

View file

@ -24,9 +24,17 @@ defmodule AshHq.Github.Monitor do
|> AshHq.Docs.read!()
|> Stream.flat_map(fn library ->
:timer.sleep(1000)
opts = []
opts =
if api_key = Application.get_env(:ash_hq, :github)[:api_key] do
Keyword.put(opts, :headers, [{"Authorization", "token #{api_key}"}])
else
opts
end
"https://api.github.com/repos/#{library.repo_org}/#{library.name}/contributors"
|> Req.get!(headers: [{"Authorization", "token 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"}])
|> Req.get!(opts)
|> case do
%{status: 200, body: body} ->
Stream.map(body, &Map.take(&1, ["id", "avatar_url", "html_url", "login"]))