chore: working on code smells
This commit is contained in:
@@ -7,6 +7,16 @@ defmodule BDS.Posts.Link do
|
||||
@primary_key {:id, :string, autogenerate: false}
|
||||
@foreign_key_type :string
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
id: String.t() | nil,
|
||||
source_post_id: String.t() | nil,
|
||||
target_post_id: String.t() | nil,
|
||||
source_post: term(),
|
||||
target_post: term(),
|
||||
link_text: String.t() | nil,
|
||||
created_at: integer() | nil
|
||||
}
|
||||
|
||||
schema "post_links" do
|
||||
belongs_to :source_post, BDS.Posts.Post, foreign_key: :source_post_id, references: :id, type: :string
|
||||
belongs_to :target_post, BDS.Posts.Post, foreign_key: :target_post_id, references: :id, type: :string
|
||||
@@ -15,6 +25,7 @@ defmodule BDS.Posts.Link do
|
||||
field :created_at, :integer
|
||||
end
|
||||
|
||||
@spec changeset(t() | Ecto.Changeset.t(), map()) :: Ecto.Changeset.t()
|
||||
def changeset(link, attrs) do
|
||||
link
|
||||
|> cast(attrs, [:id, :source_post_id, :target_post_id, :link_text, :created_at])
|
||||
|
||||
@@ -10,6 +10,35 @@ defmodule BDS.Posts.Post do
|
||||
@foreign_key_type :string
|
||||
@statuses [:draft, :published, :archived]
|
||||
|
||||
@type status :: :draft | :published | :archived
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
id: String.t() | nil,
|
||||
project_id: String.t() | nil,
|
||||
project: term(),
|
||||
title: String.t() | nil,
|
||||
slug: String.t() | nil,
|
||||
excerpt: String.t() | nil,
|
||||
content: String.t() | nil,
|
||||
status: status(),
|
||||
author: String.t() | nil,
|
||||
created_at: integer() | nil,
|
||||
updated_at: integer() | nil,
|
||||
published_at: integer() | nil,
|
||||
file_path: String.t(),
|
||||
checksum: String.t() | nil,
|
||||
tags: [String.t()],
|
||||
categories: [String.t()],
|
||||
template_slug: String.t() | nil,
|
||||
language: String.t() | nil,
|
||||
do_not_translate: boolean(),
|
||||
published_title: String.t() | nil,
|
||||
published_content: String.t() | nil,
|
||||
published_tags: String.t() | nil,
|
||||
published_categories: String.t() | nil,
|
||||
published_excerpt: String.t() | nil
|
||||
}
|
||||
|
||||
schema "posts" do
|
||||
belongs_to :project, BDS.Projects.Project, type: :string
|
||||
|
||||
@@ -36,6 +65,7 @@ defmodule BDS.Posts.Post do
|
||||
field :published_excerpt, :string
|
||||
end
|
||||
|
||||
@spec changeset(t() | Ecto.Changeset.t(), map()) :: Ecto.Changeset.t()
|
||||
def changeset(post, attrs) do
|
||||
post
|
||||
|> cast(
|
||||
|
||||
@@ -8,6 +8,25 @@ defmodule BDS.Posts.Translation do
|
||||
@foreign_key_type :string
|
||||
@statuses [:draft, :published]
|
||||
|
||||
@type status :: :draft | :published
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
id: String.t() | nil,
|
||||
translation_for: String.t() | nil,
|
||||
post: term(),
|
||||
project_id: String.t() | nil,
|
||||
language: String.t() | nil,
|
||||
title: String.t() | nil,
|
||||
excerpt: String.t() | nil,
|
||||
content: String.t() | nil,
|
||||
status: status(),
|
||||
created_at: integer() | nil,
|
||||
updated_at: integer() | nil,
|
||||
published_at: integer() | nil,
|
||||
file_path: String.t(),
|
||||
checksum: String.t() | nil
|
||||
}
|
||||
|
||||
schema "post_translations" do
|
||||
belongs_to :post, BDS.Posts.Post,
|
||||
foreign_key: :translation_for,
|
||||
@@ -27,6 +46,7 @@ defmodule BDS.Posts.Translation do
|
||||
field :checksum, :string
|
||||
end
|
||||
|
||||
@spec changeset(t() | Ecto.Changeset.t(), map()) :: Ecto.Changeset.t()
|
||||
def changeset(translation, attrs) do
|
||||
translation
|
||||
|> cast(
|
||||
|
||||
Reference in New Issue
Block a user