Skip to content

Commit

Permalink
feat: format
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedsoupe committed Jan 14, 2024
1 parent 5d0f1a2 commit 0420b19
Show file tree
Hide file tree
Showing 29 changed files with 171 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Used by "mix format"
[
imports: [:phoenix, :ecto],
inputs: ["mix.exs", "config/*.exs"],
plugins: [Phoenix.LiveView.HTMLFormatter],
inputs: ["*.{ex,exs,heex}", "{lib,test}/**/*.{ex,exs,heex}"]
]
5 changes: 3 additions & 2 deletions lib/pescarte/catalogo/models/habitat.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ defmodule Pescarte.Catalogo.Models.Habitat do

@primary_key {:nome, :string, autogenerate: false}
schema "habitat" do
field :id_publico, Pescarte.Database.Types.PublicId, autogenerate: true
field(:id_publico, Pescarte.Database.Types.PublicId, autogenerate: true)

many_to_many :peixes, Peixe,
many_to_many(:peixes, Peixe,
join_through: "peixes_habitats",
join_keys: [habitat_nome: :nome, peixe_nome_cientifico: :nome_cientifico],
on_replace: :delete,
unique: true
)

timestamps()
end
Expand Down
9 changes: 5 additions & 4 deletions lib/pescarte/catalogo/models/peixe.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ defmodule Pescarte.Catalogo.Models.Peixe do

@primary_key {:nome_cientifico, :string, autogenerate: false}
schema "peixe" do
field :link_imagem, :string
field :nativo?, :boolean, default: false
field :id_publico, Pescarte.Database.Types.PublicId, autogenerate: true
field(:link_imagem, :string)
field(:nativo?, :boolean, default: false)
field(:id_publico, Pescarte.Database.Types.PublicId, autogenerate: true)

many_to_many :habitats, Habitat,
many_to_many(:habitats, Habitat,
join_through: "peixes_habitats",
join_keys: [peixe_nome_cientifico: :nome_cientifico, habitat_nome: :nome],
on_replace: :delete,
unique: true
)

timestamps()
end
Expand Down
14 changes: 7 additions & 7 deletions lib/pescarte/cotacoes/models/cotacao.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ defmodule Pescarte.Cotacoes.Models.Cotacao do

@primary_key false
schema "cotacao" do
field :data, :date, primary_key: true
field :link, :string, primary_key: true
field :fonte, :string
field :importada?, :boolean, default: false
field :baixada?, :boolean, default: false
field :tipo, Ecto.Enum, values: ~w(pdf zip)a
field :id, Pescarte.Database.Types.PublicId, autogenerate: true
field(:data, :date, primary_key: true)
field(:link, :string, primary_key: true)
field(:fonte, :string)
field(:importada?, :boolean, default: false)
field(:baixada?, :boolean, default: false)
field(:tipo, Ecto.Enum, values: ~w(pdf zip)a)
field(:id, Pescarte.Database.Types.PublicId, autogenerate: true)
end

@spec changeset(Cotacao.t(), map) :: changeset
Expand Down
18 changes: 9 additions & 9 deletions lib/pescarte/cotacoes/models/cotacao_pescado.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ defmodule Pescarte.Cotacoes.Models.CotacaoPescado do

@primary_key false
schema "cotacoes_pescados" do
field :id, Pescarte.Database.Types.PublicId, autogenerate: true
field :cotacao_data, :date, primary_key: true
field :cotacao_link, :string
field :pescado_codigo, :string, primary_key: true
field :fonte_nome, :string, primary_key: true
field :preco_minimo, :integer
field :preco_maximo, :integer
field :preco_mais_comum, :integer
field :preco_medio, :integer
field(:id, Pescarte.Database.Types.PublicId, autogenerate: true)
field(:cotacao_data, :date, primary_key: true)
field(:cotacao_link, :string)
field(:pescado_codigo, :string, primary_key: true)
field(:fonte_nome, :string, primary_key: true)
field(:preco_minimo, :integer)
field(:preco_maximo, :integer)
field(:preco_mais_comum, :integer)
field(:preco_medio, :integer)
end

@spec changeset(CotacaoPescado.t(), map) :: changeset
Expand Down
6 changes: 3 additions & 3 deletions lib/pescarte/cotacoes/models/fonte.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ defmodule Pescarte.Cotacoes.Models.Fonte do

@primary_key {:nome, :string, autogenerate: false}
schema "fonte_cotacao" do
field :link, :string
field :descricao, :string
field :id, Pescarte.Database.Types.PublicId, autogenerate: true
field(:link, :string)
field(:descricao, :string)
field(:id, Pescarte.Database.Types.PublicId, autogenerate: true)
end

@spec changeset(Fonte.t(), map) :: changeset
Expand Down
6 changes: 3 additions & 3 deletions lib/pescarte/cotacoes/models/pescado.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ defmodule Pescarte.Cotacoes.Models.Pescado do

@primary_key {:codigo, :string, autogenerate: false}
schema "pescado" do
field :descricao, :string
field :embalagem, :string
field :id, Pescarte.Database.Types.PublicId, autogenerate: true
field(:descricao, :string)
field(:embalagem, :string)
field(:id, Pescarte.Database.Types.PublicId, autogenerate: true)
end

@spec changeset(Pescado.t(), map) :: changeset
Expand Down
4 changes: 2 additions & 2 deletions lib/pescarte/cotacoes/repository.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule Pescarte.Cotacoes.Repository do

@impl true
def find_all_cotacao_by_not_ingested do
query = from c in Cotacao, where: not c.importada?, select: c
query = from(c in Cotacao, where: not c.importada?, select: c)
Repo.Replica.all(query)
end

Expand Down Expand Up @@ -41,7 +41,7 @@ defmodule Pescarte.Cotacoes.Repository do

@impl true
def find_all_cotacao_by_not_downloaded do
query = from c in Cotacao, where: not c.baixada?, select: c
query = from(c in Cotacao, where: not c.baixada?, select: c)
Repo.Replica.all(query)
end

Expand Down
11 changes: 6 additions & 5 deletions lib/pescarte/identidades/models/contato.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ defmodule Pescarte.Identidades.Models.Contato do

@primary_key {:email_principal, :string, autogenerate: false}
schema "contato" do
field :celular_principal, :string
field :emails_adicionais, {:array, :string}
field :celulares_adicionais, {:array, :string}
field :id_publico, Pescarte.Database.Types.PublicId, autogenerate: true
field(:celular_principal, :string)
field(:emails_adicionais, {:array, :string})
field(:celulares_adicionais, {:array, :string})
field(:id_publico, Pescarte.Database.Types.PublicId, autogenerate: true)

belongs_to :endereco, Endereco,
belongs_to(:endereco, Endereco,
foreign_key: :endereco_cep,
references: :cep,
type: :string
)

timestamps()
end
Expand Down
14 changes: 7 additions & 7 deletions lib/pescarte/identidades/models/endereco.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ defmodule Pescarte.Identidades.Models.Endereco do

@primary_key {:cep, :string, autogenerate: false}
schema "endereco" do
field :bairro, :string
field :rua, :string
field :numero, :string
field :complemento, :string
field :cidade, :string
field :estado, :string
field :id_publico, Pescarte.Database.Types.PublicId, autogenerate: true
field(:bairro, :string)
field(:rua, :string)
field(:numero, :string)
field(:complemento, :string)
field(:cidade, :string)
field(:estado, :string)
field(:id_publico, Pescarte.Database.Types.PublicId, autogenerate: true)

timestamps()
end
Expand Down
13 changes: 7 additions & 6 deletions lib/pescarte/identidades/models/token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ defmodule Pescarte.Identidades.Models.Token do
}

schema "user_token" do
field :token, :binary
field :contexto, :string
field :enviado_para, :string
field(:token, :binary)
field(:contexto, :string)
field(:enviado_para, :string)

belongs_to :usuario, Usuario,
belongs_to(:usuario, Usuario,
foreign_key: :usuario_id,
references: :id_publico,
type: :string
)

timestamps(updated_at: false)
end
Expand All @@ -46,10 +47,10 @@ defmodule Pescarte.Identidades.Models.Token do
Obtém todos os tokens do usuário fornecido para os contextos fornecidos.
"""
def user_and_contexts_query(user, :all) do
from t in Token, where: t.usuario_id == ^user.id_publico
from(t in Token, where: t.usuario_id == ^user.id_publico)
end

def user_and_contexts_query(user, [_ | _] = contexts) do
from t in Token, where: t.usuario_id == ^user.id_publico and t.contexto in ^contexts
from(t in Token, where: t.usuario_id == ^user.id_publico and t.contexto in ^contexts)
end
end
3 changes: 2 additions & 1 deletion lib/pescarte/modulo_pesquisa/i_manage_repository.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ defmodule Pescarte.ModuloPesquisa.IManageRepository do
{:ok, Categoria.t()} | {:error, changeset}
@callback fetch_midia_by_id_publico(Pescarte.Database.id()) ::
{:ok, Midia.t()} | {:error, changeset}
@callback fetch_tag_by_id_publico(Pescarte.Database.id()) :: {:ok, Tag.t()} | {:error, changeset}
@callback fetch_tag_by_id_publico(Pescarte.Database.id()) ::
{:ok, Tag.t()} | {:error, changeset}
@callback fetch_tag_by_etiqueta(binary) :: {:ok, Tag.t()} | {:error, changeset}
@callback fetch_tags_from_ids(list(Pescarte.Database.id())) :: list(Tag.t())

Expand Down
11 changes: 6 additions & 5 deletions lib/pescarte/modulo_pesquisa/models/campus.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ defmodule Pescarte.ModuloPesquisa.Models.Campus do

@primary_key {:acronimo, :string, autogenerate: false}
schema "campus" do
field :nome, :string
field :nome_universidade, :string
field :id_publico, PublicId, autogenerate: true
field(:nome, :string)
field(:nome_universidade, :string)
field(:id_publico, PublicId, autogenerate: true)

has_many :pesquisadores, Pesquisador, foreign_key: :campus_acronimo, references: :acronimo
has_many(:pesquisadores, Pesquisador, foreign_key: :campus_acronimo, references: :acronimo)

belongs_to :endereco, Endereco,
belongs_to(:endereco, Endereco,
on_replace: :delete,
foreign_key: :endereco_cep,
references: :cep,
type: :string
)

timestamps()
end
Expand Down
15 changes: 9 additions & 6 deletions lib/pescarte/modulo_pesquisa/models/linha_pesquisa.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,28 @@ defmodule Pescarte.ModuloPesquisa.Models.LinhaPesquisa do

@primary_key {:numero, :integer, autogenerate: false}
schema "linha_pesquisa" do
field :desc_curta, :string
field :desc, :string
field :id_publico, Pescarte.Database.Types.PublicId, autogenerate: true
field(:desc_curta, :string)
field(:desc, :string)
field(:id_publico, Pescarte.Database.Types.PublicId, autogenerate: true)

belongs_to :nucleo_pesquisa, NucleoPesquisa,
belongs_to(:nucleo_pesquisa, NucleoPesquisa,
foreign_key: :nucleo_pesquisa_letra,
references: :letra,
type: :string
)

belongs_to :responsavel_lp, Pesquisador,
belongs_to(:responsavel_lp, Pesquisador,
foreign_key: :responsavel_lp_id,
references: :id_publico,
type: :string
)

many_to_many :pesquisadores, Pesquisador,
many_to_many(:pesquisadores, Pesquisador,
join_through: "linhas_pesquisas_pesquisadores",
join_keys: [pesquisador_id: :id_publico, linha_pesquisa_numero: :numero],
on_replace: :delete,
unique: true
)

timestamps()
end
Expand Down
22 changes: 12 additions & 10 deletions lib/pescarte/modulo_pesquisa/models/midia.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,27 @@ defmodule Pescarte.ModuloPesquisa.Models.Midia do

@primary_key {:link, :string, autogenerate: false}
schema "midia" do
field :tipo, Ecto.Enum, values: @tipos
field :nome_arquivo, :string
field :data_arquivo, :date
field :restrito?, :boolean, default: false
field :observacao, :string
field :texto_alternativo, :string
field :id_publico, PublicId, autogenerate: true

belongs_to :autor, Usuario,
field(:tipo, Ecto.Enum, values: @tipos)
field(:nome_arquivo, :string)
field(:data_arquivo, :date)
field(:restrito?, :boolean, default: false)
field(:observacao, :string)
field(:texto_alternativo, :string)
field(:id_publico, PublicId, autogenerate: true)

belongs_to(:autor, Usuario,
on_replace: :update,
foreign_key: :autor_id,
references: :id_publico,
type: :string
)

many_to_many :tags, Tag,
many_to_many(:tags, Tag,
join_through: "midias_tags",
join_keys: [midia_link: :link, tag_etiqueta: :etiqueta],
on_replace: :delete,
unique: true
)

timestamps()
end
Expand Down
4 changes: 2 additions & 2 deletions lib/pescarte/modulo_pesquisa/models/midia/categoria.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ defmodule Pescarte.ModuloPesquisa.Models.Midia.Categoria do

@primary_key {:nome, :string, autogenerate: false}
schema "categoria" do
field :id_publico, Pescarte.Database.Types.PublicId, autogenerate: true
field(:id_publico, Pescarte.Database.Types.PublicId, autogenerate: true)

has_many :tags, Tag, foreign_key: :categoria_nome, references: :nome
has_many(:tags, Tag, foreign_key: :categoria_nome, references: :nome)

timestamps()
end
Expand Down
5 changes: 3 additions & 2 deletions lib/pescarte/modulo_pesquisa/models/midia/tag.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ defmodule Pescarte.ModuloPesquisa.Models.Midia.Tag do

@primary_key {:etiqueta, :string, autogenerate: false}
schema "tag" do
field :id_publico, Pescarte.Database.Types.PublicId, autogenerate: true
field(:id_publico, Pescarte.Database.Types.PublicId, autogenerate: true)

belongs_to :categoria, Categoria,
belongs_to(:categoria, Categoria,
foreign_key: :categoria_nome,
references: :nome,
type: :string
)

timestamps()
end
Expand Down
8 changes: 4 additions & 4 deletions lib/pescarte/modulo_pesquisa/models/nucleo_pesquisa.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ defmodule Pescarte.ModuloPesquisa.Models.NucleoPesquisa do

@primary_key {:letra, :string, autogenerate: false}
schema "nucleo_pesquisa" do
field :nome, :string
field :desc, :string
field :id_publico, Pescarte.Database.Types.PublicId, autogenerate: true
field(:nome, :string)
field(:desc, :string)
field(:id_publico, Pescarte.Database.Types.PublicId, autogenerate: true)

has_many :linha_pesquisas, LinhaPesquisa, foreign_key: :nucleo_pesquisa_letra
has_many(:linha_pesquisas, LinhaPesquisa, foreign_key: :nucleo_pesquisa_letra)

timestamps()
end
Expand Down
Loading

0 comments on commit 0420b19

Please sign in to comment.