I ❤️ ❤️ ❤️ how you can build Ecto schemas on top of database views just like you can with tables. This let me push the data logic for streaks down into the database and allow a much simpler querying syntax (no raw SQL) in the Elixir code. A refactor of the streaks query also enabled richer querying, such as for the longest streak as well as the current one:
I ❤️ ❤️ ❤️ how you can build Ecto schemas on top of database views just like you can with tables. This let me push the data logic for streaks down into the database and allow a much simpler querying syntax (no raw SQL) in the Elixir code. A refactor of the streaks query also enabled richer querying, such as for the longest streak as well as the current one: