Transformation: Take First n Items

Our next transformation is to extract the first count entries from the list. Rather than write a function, we’ll use the built-in Enum.take:

 
def​ process({user, project, count}) ​do
 
Issues.GithubIssues.fetch(user, project)
 
|> decode_response
 
|> convert_to_list_of_hashdicts
 
|> sort_into_ascending_order
*
|> Enum.take(count)
 
end

Get Programming Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.