State of Elixir 2024 Results
:ok
:results_loaded
App source
This app is built from the following notebook source:
state_of_elixir_2024_results.livemd
<!-- livebook:{"app_settings":{"access_type":"public","show_source":true,"slug":"state-of-elixir-2024","zero_downtime":true},"persist_outputs":true} -->
# State of Elixir 2024 Results
```elixir
Mix.install([
{:kino, "~> 0.11.0"},
{:kino_vega_lite, "~> 0.1.10"},
{:kino_explorer, "~> 0.1.11"},
{:jason, "~> 1.4"}
])
```
## Table of contents
```elixir
require Kino.RPC
node = String.to_atom(System.fetch_env!("LB_SERVER_NAME"))
Node.set_cookie(node, String.to_atom(System.fetch_env!("LB_SERVER_COOKIE")))
results =
Kino.RPC.eval_string(
node,
~S"""
alias StateOfElixir.{Repo, Response}
Response
|> Repo.all()
|> Enum.map(&Map.from_struct/1)
|> Enum.map(&Map.filter(&1, fn {key, _} -> key != :request_metadata end))
""",
file: __ENV__.file
)
:results_loaded
```
```elixir
Kino.Download.new(
fn -> :binary.list_to_bin(results) end,
filename: "results.bin",
label: "Binary results data"
)
```
```elixir
VegaLite.new(width: 600, title: "Number of survey responses")
|> VegaLite.data_from_values(results, only: ["inserted_at"])
|> VegaLite.mark(:point)
|> VegaLite.encode_field(:x, "inserted_at", type: :temporal)
|> VegaLite.encode(:y, aggregate: :count)
```
```elixir
countries = Enum.map(results, &%{country: &1.user_answers.country})
VegaLite.new(width: 300)
|> VegaLite.data_from_values(countries, only: ["country"])
|> VegaLite.mark(:bar)
|> VegaLite.encode_field(:x, "country", type: :nominal)
|> VegaLite.encode(:y, aggregate: :count)
|> VegaLite.encode_field(:color, "country", type: :nominal)
```
```elixir
gender = Enum.map(results, &%{gender: &1.user_answers.gender})
VegaLite.new(width: 300, title: "Gender")
|> VegaLite.data_from_values(gender, only: ["gender"])
|> VegaLite.mark(:bar)
|> VegaLite.encode_field(:x, "gender", type: :nominal)
|> VegaLite.encode(:y, aggregate: :count)
|> VegaLite.encode_field(:color, "gender", type: :nominal)
```