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

camatcode / basenji / 5598603d7c8d0dbfc880cb303655deb2a5fb6932

07 Jul 2025 05:26AM UTC coverage: 65.799% (+0.9%) from 64.928%
5598603d7c8d0dbfc880cb303655deb2a5fb6932

push

github

web-flow
Merge pull request #26 from camatcode/work/snapshot-processing

feat(comics): add image preview

24 of 29 new or added lines in 6 files covered. (82.76%)

379 of 576 relevant lines covered (65.8%)

359.3 hits per line

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

86.67
/lib/basenji_web/controllers/api/comics_controller.ex
1
defmodule BasenjiWeb.ComicsController do
2
  @moduledoc false
3
  use BasenjiWeb, :controller
4

5
  alias Basenji.Comics
6
  alias BasenjiWeb.API.Utils
7

8
  def get_page(conn, params) do
9
    id = params["id"]
4✔
10
    page = params["page"]
4✔
11

NEW
12
    with {:ok, page_num} <- Utils.safe_to_int(page) do
×
13
      Comics.get_page(id, page_num)
4✔
14
    end
15
    |> case do
4✔
16
      {:ok, binary, mime} ->
17
        length = byte_size(binary)
4✔
18

19
        conn
20
        |> merge_resp_headers([{"access-control-allow-origin", "*"}])
21
        |> merge_resp_headers([{"content-type", mime}])
22
        |> merge_resp_headers([{"content-length", "#{length}"}])
4✔
23
        |> merge_resp_headers([{"content-disposition", "attachment"}])
24
        |> send_resp(200, binary)
4✔
25

26
      error ->
27
        Utils.bad_request_handler(conn, error)
×
28
    end
29
  end
30

31
  def get_preview(conn, params) do
32
    id = params["id"]
2✔
33

34
    Comics.get_image_preview(id)
35
    |> case do
2✔
36
      {:ok, binary} ->
37
        length = byte_size(binary)
1✔
38

39
        conn
40
        |> merge_resp_headers([{"access-control-allow-origin", "*"}])
41
        |> merge_resp_headers([{"content-type", "image/jpeg"}])
42
        |> merge_resp_headers([{"content-length", "#{length}"}])
1✔
43
        |> merge_resp_headers([{"content-disposition", "attachment"}])
44
        |> send_resp(200, binary)
1✔
45

46
      error ->
47
        Utils.bad_request_handler(conn, error)
1✔
48
    end
49
  end
50
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