Skip to content

Commit 71a3d34

Browse files
committed
lower search result amount because of rate limits
1 parent fdf3a69 commit 71a3d34

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

lib/chuko/api/anibis.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ defmodule Chuko.Api.Anibis do
3131
|> Req.get!(put_in(options[:params][:ps], 1))
3232
|> then(fn %Req.Response{body: body} -> body["pagingInfo"]["totalItems"] end)
3333

34-
pages = ceil(amount / 120)
34+
pages =
35+
ceil(amount / 120)
36+
# Capping for rate limit reasons
37+
|> then(&if &1 > 5, do: 5, else: &1)
3538

3639
1..pages
3740
|> Task.async_stream(

lib/chuko/api/ricardo.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ defmodule Chuko.Api.Ricardo do
2626
|> Req.get!()
2727
|> then(fn %Req.Response{body: body} -> body["totalArticlesCount"] end)
2828

29-
pages = ceil(amount / 60)
29+
pages =
30+
ceil(amount / 60)
31+
# Capping for rate limit reasons
32+
|> then(&if &1 > 10, do: 10, else: &1)
3033

3134
1..pages
3235
|> Task.async_stream(

lib/chuko/api/tutti_gql.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ defmodule Chuko.Api.TuttiGql do
297297
|> then(fn %Req.Response{body: body} ->
298298
body["data"]["searchListingsByQuery"]["listings"]["totalCount"]
299299
end)
300-
|> then(&if &1 > 3000, do: 3000, else: &1)
300+
# Max is 3000 but capping at 500 for rate limit reasons
301+
|> then(&if &1 > 500, do: 500, else: &1)
301302

302303
0..floor(amount / 100)
303304
|> Enum.map(&(&1 * 100))

0 commit comments

Comments
 (0)