O'Reilly logo

Programming Elixir by Dave Thomas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Transformation: Sort Data

Look at our original “design.”

 

images/conveyor.png

We’re making good progress—we’ve coded all of the top conveyor belt. Our next transformation is to sort the data on its created_at field. And this can just use a standard Elixir library function, sort/2. We could create a new module for this, but it would be pretty lonely. For now we’ll put the function in the CLI module and keep an eye out for opportunities to move it out if we add related functions later.

So now our CLI module contains

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required