Skip to content

Commit

Permalink
Renaming number, removing unecessary else
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason S committed Jun 22, 2015
1 parent acd5695 commit 8084801
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/jsonapi.ex
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,19 @@ defmodule JSONAPI do
self: mod.url_func().(endpoint, :index, params),
}

number = get_in(params, [:page, :number])
page_number = get_in(params, [:page, :number])
page_size = get_in(params, [:page, :size])
resources = Map.get(doc, :data, [])

if number && page_size do
if page_number && page_size do

if Enum.count(resources) == page_size do
next_page = mod.url_func().(endpoint, :index, put_in(params, [:page, :number], number+1))
next_page = mod.url_func().(endpoint, :index, put_in(params, [:page, :number], page_number+1))
links = Dict.put(links, :next_page, next_page)
else
end

if number > 0 do
previous_page = mod.url_func().(endpoint, :index, put_in(params, [:page, :number], number-1))
if page_number > 0 do
previous_page = mod.url_func().(endpoint, :index, put_in(params, [:page, :number], page_number-1))
links = Dict.put(links, :previous_page, previous_page)
end

Expand Down

0 comments on commit 8084801

Please sign in to comment.