wip: currently rewriting the project as a full stack application tangled.org/kacaii.dev/sigo
gleam
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

:card_file_box: add support for querying how many brigades are active

Kacaii 79a930fb 5daa65e6

+36
+33
src/app/sql.gleam
··· 7 7 import gleam/dynamic/decode 8 8 import pog 9 9 10 + /// A row you get from running the `count_active_brigades` query 11 + /// defined in `./src/app/sql/count_active_brigades.sql`. 12 + /// 13 + /// > 🐿️ This type definition was generated automatically using v4.4.1 of the 14 + /// > [squirrel package](https://github.com/giacomocavalieri/squirrel). 15 + /// 16 + pub type CountActiveBrigadesRow { 17 + CountActiveBrigadesRow(count: Int) 18 + } 19 + 20 + /// Runs the `count_active_brigades` query 21 + /// defined in `./src/app/sql/count_active_brigades.sql`. 22 + /// 23 + /// > 🐿️ This function was generated automatically using v4.4.1 of 24 + /// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). 25 + /// 26 + pub fn count_active_brigades( 27 + db: pog.Connection, 28 + ) -> Result(pog.Returned(CountActiveBrigadesRow), pog.QueryError) { 29 + let decoder = { 30 + use count <- decode.field(0, decode.int) 31 + decode.success(CountActiveBrigadesRow(count:)) 32 + } 33 + 34 + "SELECT COUNT(id) 35 + FROM brigade 36 + WHERE is_active = TRUE; 37 + " 38 + |> pog.query 39 + |> pog.returning(decoder) 40 + |> pog.execute(db) 41 + } 42 + 10 43 /// Runs the `register_new_user` query 11 44 /// defined in `./src/app/sql/register_new_user.sql`. 12 45 ///
+3
src/app/sql/count_active_brigades.sql
··· 1 + SELECT COUNT(id) 2 + FROM brigade 3 + WHERE is_active = TRUE;