Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gen qr codes task #373

Merged
merged 4 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,5 @@ tags
*.in
temp
pdf/
qrs/
*.zip
23 changes: 15 additions & 8 deletions lib/mix/tasks/gen.qrcodes.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
defmodule Mix.Tasks.Gen.QrCodes do
@moduledoc """
Task to generate the QR codes for the attendees

Expects FRONTEND_URL variable to be set.
Example: https://seium.org
"""
use Mix.Task

Expand All @@ -24,17 +27,21 @@ defmodule Mix.Tasks.Gen.QrCodes do

if arg == "attendees" do
Enum.each(Accounts.list_attendees(), fn attendee ->
QrCodeSvg.generate(
"#{url}attendees/#{attendee.id}",
"attendee_#{attendee.id}.svg"
)
qr =
"#{url}/attendees/#{attendee.id}"
|> QRCodeEx.encode()
|> QRCodeEx.png(width: 460)

File.write("qrs/#{attendee.id}.png", qr, [:binary])
end)
else
Enum.each(Contest.list_referrals(), fn referral ->
QrCodeSvg.generate(
"#{url}referrals/#{referral.id}",
"referral_#{referral.id}.svg"
)
qr =
"#{url}/referrals/#{referral.id}"
|> QRCodeEx.encode()
|> QRCodeEx.png(width: 460)

File.write("referrals/#{referral.id}.png", qr, [:binary])
end)
end
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ defmodule Safira.MixProject do
{:guardian, "~> 2.3"},
{:comeonin, "~> 5.3"},
{:bcrypt_elixir, "~> 3.0"},
{:qr_code_svg, git: "https://github.com/ondrej-tucek/qr-code-svg", tag: "v1.2.0"},
{:cors_plug, "~> 3.0"},
{:arc, "~> 0.11.0"},
{:qrcode_ex, "~> 0.1.0"},
# If using Amazon S3
{:ex_aws, "~> 2.4"},
{:ex_aws_s3, "~> 2.3"},
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"pow": {:hex, :pow, "1.0.31", "5787b9520af180535f05cef4e04ad64f3c1be3b6d407ef9b1a64e9eba5bc66fb", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.3.0 and < 1.8.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, ">= 2.0.0 and < 4.0.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, ">= 0.18.0", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:plug, ">= 1.5.0 and < 2.0.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "988d9af08b7380c5b95fc65d1325642dd96defde3f0a7a103c52d5e2390d888f"},
"qr_code_svg": {:git, "https://github.com/ondrej-tucek/qr-code-svg", "febda672fcde25cc071ee84b556f650237751361", [tag: "v1.2.0"]},
"qrcode": {:git, "https://github.com/sunboshan/qrcode.git", "f6855c378b0d11e2aef6fb8c071280f367350643", [tag: nil]},
"qrcode_ex": {:hex, :qrcode_ex, "0.1.1", "8907a7558325babd30f7f43ff85a0169ef65c30820d68e90d792802318f9a062", [:mix], [], "hexpm", "9eb0b397fb3a1c3b16e55b6de6f845a0b4e7b7100ade39eb59fad98fb62455a7"},
"quantum": {:hex, :quantum, "3.5.0", "8d2c5ba68c55991e8975aca368e3ab844ba01f4b87c4185a7403280e2c99cf34", [:mix], [{:crontab, "~> 1.1", [hex: :crontab, repo: "hexpm", optional: false]}, {:gen_stage, "~> 0.14 or ~> 1.0", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.2", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "cab737d1d9779f43cb1d701f46dd05ea58146fd96238d91c9e0da662c1982bb6"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"scrivener": {:hex, :scrivener, "2.7.2", "1d913c965ec352650a7f864ad7fd8d80462f76a32f33d57d1e48bc5e9d40aba2", [:mix], [], "hexpm", "7866a0ec4d40274efbee1db8bead13a995ea4926ecd8203345af8f90d2b620d9"},
Expand Down
Loading