Skip to content

Instantly share code, notes, and snippets.

defmodule Bonfire.Common.EnvConfig do
@moduledoc """
A Want type that reads environment variables and returns them as keyword lists or map(s).
## Features
- Collects environment variables with a specified prefix.
- Allows key transformation via `:transform_keys`.
- Supports type casting via `:want_values` using the `Want` library.
- Supports both single (e.g. `MYAPP_DB_HOST`) and a list of configuration groups (e.g. `MYAPP_DB_1_HOST`, `MYAPP_DB_2_HOST`, etc).
defmodule Bonfire.Social.Feeds.Presets do
@moduledoc """
Preset feed definitions
"""
use Bonfire.Common.E
import Bonfire.Common.Utils
alias Bonfire.Common.Config
alias Bonfire.Common.Types
defmodule Bonfire.Social.Feeds.Funnel do
@moduledoc """
Determines the appropriate filters, joins, and/or preloads for feed queries based.
Helper for `Bonfire.Social.Feeds` and `Bonfire.Social.FeedActivities`, and `Bonfire.Social.Activities`.
"""
use Bonfire.Common.E
alias Bonfire.Common.Config
[debug] query with deferred join: #Ecto.Query<from p0 in Needle.Pointer, as: :main_object,
left_join: a1 in assoc(p0, :activity), as: :activity,
join: f2 in ^#Ecto.Query<from f0 in subquery(from f0 in Bonfire.Data.Social.FeedPublish,
as: :main_object,
join: a1 in Bonfire.Data.Social.Activity,
as: :activity,
on: a1.id == f0.id,
join: p2 in Needle.Pointer,
as: :activity_pointer,
@mayel
mayel / explain.sql
Last active October 26, 2024 17:55
[warning] Slow database query: ok db=10449ms repo=Elixir.Bonfire.Common.Repo
EXPLAIN ( ANALYZE TRUE, VERBOSE FALSE, COSTS TRUE, TIMING TRUE, SUMMARY TRUE, FORMAT TEXT ) SELECT b0."id", b0."feed_id", b1."id", b1."subject_id", b1."verb_id", b1."object_id", b15."id", b15."is_sensitive", b20."id", b20."reply_to_id", b20."thread_id", b20."direct_replies_count", b20."nested_replies_count", b20."total_replies_count", b20."path", p3."id", p3."table_id", p3."deleted_at", b18."id", b18."name", b18."summary", b18."website", b18."location", b18."icon_id", b18."image_id", b19."id", b19."creator_id", b19."path", b19."file", b19."size", b19."media_type", b19."metadata", b19."deleted_at", b17."id", b17."username", b17."username_hash", b17."outbox_id", b17."inbox_id", b17."notifications_id", b10."id", b10."creator_id", p11."id", p11."table_id", p11."deleted_at", b13."id", b13."name", b13."summary", b13."website", b13."location", b13."icon_id", b13."image_id", b14."id", b14."creator_id", b14."path", b14."file", b14."size",
SELECT
p0."id",
p0."table_id",
p0."deleted_at",
b1."id",
b1."subject_id",
b1."verb_id",
b1."object_id",
b13."id",
b13."is_sensitive",
SELECT
b0."id",
b0."feed_id",
b1."id",
b1."subject_id",
b1."verb_id",
b1."object_id",
b15."id",
b15."is_sensitive",
b20."id",
iex(12)> M.infinity
1 : one (0 zeros)
10 : ten (1 zeros)
100 : one hundred (2 zeros)
1000 : one thousand (3 zeros)
10000 : ten thousand (4 zeros)
100000 : one hundred thousand (5 zeros)
1000000 : one million (6 zeros)
10000000 : ten million (7 zeros)
defmodule UserInput do
@doc "Takes a data structure and converts any keys in maps to (previously defined) atoms, recursively. By default any unknown string keys will be discarded. It can optionally also convert string values to known atoms as well."
def input_to_atoms(
data,
opts \\ []
)
def input_to_atoms(data, opts) do
opts =
@mayel
mayel / deps.ex
Last active September 30, 2023 10:00
bonfire deps by app size
[
bonfire: %{total: "3.56GiB", deps: "1.95GiB", app: "2.8MiB},
bonfire_ui_common: %{total: "2.04GiB", deps: "346.71MiB", app: "1.70GiB"},
iconify_ex: %{total: "333.30MiB", deps: "2.99MiB", app: "330.31MiB"},
bonfire_editor_milkdown: %{total: "1.80GiB", deps: "1.70GiB", app: "96.43MiB"},
ex_doc: %{total: "53.90MiB", deps: "423.44KiB", app: "53.49MiB"},
text_corpus_udhr: %{total: "45.08MiB", deps: "70.67KiB", app: "45.01MiB"},
bonfire_ui_me: %{total: "1.74GiB", deps: "1.70GiB", app: "32.16MiB"},
bonfire_editor_quill: %{total: "1.73GiB", deps: "1.70GiB", app: "27.69MiB"},
paper_trail: %{total: "22.43MiB", deps: "8.61MiB", app: "13.83MiB"},