Skip to content

Commit 74a53e5

Browse files
committed
Cleanup
1 parent ab36a43 commit 74a53e5

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

lib/code_corps/github/api/eager_api.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defmodule CodeCorps.GitHub.EagerAPI do
5151
end
5252

5353
def retrieve_total_pages(headers) do
54-
case headers |> IO.inspect |> List.keyfind("Link", 0, nil) do
54+
case headers |> List.keyfind("Link", 0, nil) do
5555
nil -> 1
5656
{"Link", value} -> value |> extract_total_pages
5757
end
@@ -73,7 +73,6 @@ defmodule CodeCorps.GitHub.EagerAPI do
7373
|> URI.decode_query
7474
|> Map.get("page")
7575
|> String.to_integer
76-
|> IO.inspect
7776
end
7877

7978
defp process_page({nil, nil}, _, _) do

lib/code_corps/github/api/repository.ex

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,35 @@ defmodule CodeCorps.GitHub.API.Repository do
2323
end
2424

2525
defp fetch_issues(%GithubRepo{github_account_login: owner, name: repo}, access_token) do
26+
path = "repos/#{owner}/#{repo}/issues"
27+
opts = [access_token: access_token]
2628
# stream/lazy
2729

2830
before_operation = Timex.now
29-
30-
results =
31-
"repos/#{owner}/#{repo}/issues?per_page=8"
32-
|> GitHub.lazy_get_all(%{}, [access_token: access_token])
33-
|> Enum.to_list
34-
|> List.flatten
35-
31+
results = path |> fetch_lazy(opts)
3632
after_operation = Timex.now
37-
3833
IO.puts("Retrieving #{results |> Enum.count} took #{Timex.diff(after_operation, before_operation)} microseconds")
3934

4035
# eager
4136

4237
before_operation = Timex.now
38+
results = path |> fetch_eager(opts)
39+
after_operation = Timex.now
40+
IO.puts("Retrieving #{results |> Enum.count} took #{Timex.diff(after_operation, before_operation)} microseconds")
4341

44-
results =
45-
"repos/#{owner}/#{repo}/issues?per_page=8"
46-
|> GitHub.eager_get_all(%{}, [access_token: access_token])
47-
|> Enum.to_list
48-
|> List.flatten
42+
results
43+
end
4944

50-
after_operation = Timex.now
45+
defp fetch_lazy(path, opts) do
46+
path
47+
|> GitHub.lazy_get_all(%{}, opts)
48+
|> Enum.to_list
49+
|> List.flatten
50+
end
5151

52-
IO.puts("Retrieving #{results |> Enum.count} took #{Timex.diff(after_operation, before_operation)} microseconds")
52+
defp fetch_eager(path, opts) do
53+
path
54+
|> GitHub.eager_get_all(%{}, opts)
55+
|> List.flatten
5356
end
5457
end

0 commit comments

Comments
 (0)