• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

camatcode / basenji / 2e6209bb8bd33c5abee4e197dc26ddac2cc0b66e

05 Jul 2025 03:06AM UTC coverage: 59.566% (-1.9%) from 61.462%
2e6209bb8bd33c5abee4e197dc26ddac2cc0b66e

Pull #23

github

camatcode
feat(comics): wrapper for plug to handle error case
Pull Request #23: feat(comics): using plug for json_api

37 of 53 new or added lines in 7 files covered. (69.81%)

302 of 507 relevant lines covered (59.57%)

291.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/lib/basenji/context_utils.ex
1
defmodule Basenji.ContextUtils do
2
  @moduledoc false
3

4
  import Ecto.Query, warn: false
5

6
  defp safe_to_existing_atom(thing) do
4✔
7
    String.to_existing_atom(thing)
4✔
8
  rescue
NEW
9
    _ -> nil
×
10
  end
11

12
  defp expand_search_opts(opts) do
13
    if is_map(opts[:search]) do
415✔
14
      expanded = Keyword.new(opts[:search], fn {k, v} -> {safe_to_existing_atom(k), v} end)
4✔
15

16
      Keyword.merge(expanded, opts)
17
      |> Keyword.delete(:search)
4✔
18
    else
19
      opts
411✔
20
    end
21
  end
22

23
  def reduce_opts(query, opts) do
24
    opts = expand_search_opts(opts)
415✔
25

26
    q =
415✔
27
      Enum.reduce(opts, query, fn
28
        {_any, ""}, query ->
NEW
29
          query
×
30

31
        {_any, nil}, query ->
32
          query
60✔
33

34
        {:inserted_before, dt}, query ->
35
          where(query, [c], c.inserted_at < ^dt)
3✔
36

37
        {:inserted_after, dt}, query ->
38
          where(query, [c], c.inserted_at > ^dt)
3✔
39

40
        {:updated_before, dt}, query ->
41
          where(query, [c], c.updated_at < ^dt)
2✔
42

43
        {:updated_after, dt}, query ->
44
          where(query, [c], c.updated_at > ^dt)
3✔
45

46
        {:offset, offset}, query ->
47
          offset(query, [p], ^offset)
20✔
48

49
        {:order_by, order}, query ->
50
          order_by(query, [], ^order)
73✔
51

52
        {:preload, pre}, query ->
53
          preload(query, [], ^pre)
73✔
54

55
        {:limit, lim}, query ->
56
          limit(query, [], ^lim)
24✔
57

58
        _, query ->
59
          query
514✔
60
      end)
61

62
    {q, opts}
63
  end
64
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc