This post demonstrates how to order an ecto query by a text field. by sending the order raw sql query through Ecto.Query.API.fragment/1
Sample table Assuming we want to query a table containing a list of scheduled jobs with known statuses. e.g RUNNING, PENDING, COMPLETED, FAILED
id task_ref status last_exec_timestamp 1 2232323 PENDING 1605726253 2 2232324 FAILED 1605726153 4 2232326 RUNNING 1605726233 5 2232326 RUNNING 1605726233 6 2232326 FAILED 1605726233 7 2232326 COMPLETED 1605726233 8 2232326 FAILED 1605726233 Our objective is to: Read More...