This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule TestSvc.MixProject do | |
use Mix.Project | |
def project do | |
[ | |
app: :test_svc, | |
version: "0.1.0", | |
elixir: "~> 1.12", | |
elixirc_paths: elixirc_paths(Mix.env()), | |
compilers: [:gettext] ++ Mix.compilers(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export POD_A_RECORD=$(echo $POD_IP | sed 's/\./-/g') | |
export RELEASE_DISTRIBUTION=name | |
export RELEASE_NODE=test_svc@${POD_A_RECORD}.${NAMESPACE}.pod.cluster.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule QuiqupFleetWeb.LiveHelpers do | |
@moduledoc """ | |
Helpers for Web components used in live view | |
""" | |
import Phoenix.LiveView | |
import Phoenix.LiveView.Helpers | |
@doc """ | |
Renders a datetime using the browser based toLocaleString methods. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Phoenix | |
config :esbuild, | |
version: "0.12.18", | |
default: [ | |
args: | |
~w(js/app.js --bundle --target=es2019 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), | |
cd: Path.expand("../assets", __DIR__), | |
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list_groups(region \\ nil, search \\ nil) do | |
query = | |
from(g in Group) | |
|> filter_region(region) | |
|> add_rank(region) | |
|> search(search) | |
query |> Repo.all() | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list_groups(region \\ nil, search \\ nil) do | |
query = | |
from(g in Group) | |
|> filter_region(region) | |
|> add_rank(region) | |
query |> Repo.all() | |
end | |
# When no region is past we don't need to partition, we have global rank |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list_groups(region \\ nil, search \\ nil) do | |
query = | |
from(g in Group) | |
|> filter_region(region) | |
query |> Repo.all() | |
end | |
defp filter_region(query, nil), do: query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/groups.ex | |
defmodule TestApp.Groups do | |
import Ecto.Query | |
alias TestApp.Repo | |
alias TestApp.Groups.Group | |
@doc """ | |
Create a new group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test/support/fixtures/group_fixtures.exs | |
defmodule TestApp.GroupFixtures do | |
@doc """ | |
Generate groups. | |
""" | |
def group_fixtures() do | |
[ | |
{"AE Group 1", "UAE", 10}, | |
{"AE Group 2", "UAE", 30}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# priv/repo/migrations/20220319222511_create_groups.exs | |
defmodule TestApp.Repo.Migrations.CreateGroups do | |
use Ecto.Migration | |
def change do | |
create table(:groups) do | |
add :name, :string, null: false | |
add :region, :string, null: false | |
add :score, :integer, null: false, default: 0 |