mirror of
https://github.com/ash-project/ash_hq.git
synced 2024-09-19 12:53:49 +12:00
chore: format
This commit is contained in:
parent
329878c272
commit
8a2b7285d9
12 changed files with 140 additions and 141 deletions
|
@ -3,15 +3,6 @@ defmodule AshHq.Discord.Attachment do
|
|||
use Ash.Resource,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
postgres do
|
||||
table "discord_attachments"
|
||||
repo AshHq.Repo
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
end
|
||||
|
||||
attributes do
|
||||
integer_primary_key :id, generated?: false, writable?: true
|
||||
attribute :filename, :string
|
||||
|
@ -28,4 +19,13 @@ defmodule AshHq.Discord.Attachment do
|
|||
attribute_type :integer
|
||||
end
|
||||
end
|
||||
|
||||
postgres do
|
||||
table "discord_attachments"
|
||||
repo AshHq.Repo
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,22 @@ defmodule AshHq.Discord.Channel do
|
|||
use Ash.Resource,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
attributes do
|
||||
integer_primary_key :id, writable?: true, generated?: false
|
||||
|
||||
attribute :name, :string do
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
attribute :order, :integer do
|
||||
allow_nil? false
|
||||
end
|
||||
end
|
||||
|
||||
relationships do
|
||||
has_many :threads, AshHq.Discord.Thread
|
||||
end
|
||||
|
||||
postgres do
|
||||
table "discord_channels"
|
||||
repo AshHq.Repo
|
||||
|
@ -24,20 +40,4 @@ defmodule AshHq.Discord.Channel do
|
|||
define :read
|
||||
define :upsert
|
||||
end
|
||||
|
||||
attributes do
|
||||
integer_primary_key :id, writable?: true, generated?: false
|
||||
|
||||
attribute :name, :string do
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
attribute :order, :integer do
|
||||
allow_nil? false
|
||||
end
|
||||
end
|
||||
|
||||
relationships do
|
||||
has_many :threads, AshHq.Discord.Thread
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,25 @@ defmodule AshHq.Discord.Message do
|
|||
data_layer: AshPostgres.DataLayer,
|
||||
extensions: [AshHq.Docs.Extensions.RenderMarkdown, AshHq.Docs.Extensions.Search]
|
||||
|
||||
attributes do
|
||||
integer_primary_key :id, generated?: false, writable?: true
|
||||
|
||||
attribute :author, :string do
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
attribute :content, :string
|
||||
attribute :content_html, :string
|
||||
|
||||
attribute :timestamp, :utc_datetime do
|
||||
allow_nil? false
|
||||
end
|
||||
end
|
||||
|
||||
render_markdown do
|
||||
render_attributes content: :content_html
|
||||
end
|
||||
|
||||
search do
|
||||
doc_attribute :content
|
||||
|
||||
|
@ -17,7 +36,17 @@ defmodule AshHq.Discord.Message do
|
|||
]
|
||||
|
||||
has_name_attribute? false
|
||||
weight_content -0.7
|
||||
weight_content(-0.7)
|
||||
end
|
||||
|
||||
relationships do
|
||||
belongs_to :thread, AshHq.Discord.Thread do
|
||||
attribute_type :integer
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
has_many :attachments, AshHq.Discord.Attachment
|
||||
has_many :reactions, AshHq.Discord.Reaction
|
||||
end
|
||||
|
||||
postgres do
|
||||
|
@ -25,10 +54,6 @@ defmodule AshHq.Discord.Message do
|
|||
repo AshHq.Repo
|
||||
end
|
||||
|
||||
render_markdown do
|
||||
render_attributes content: :content_html
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults [:read, :destroy]
|
||||
|
||||
|
@ -57,31 +82,6 @@ defmodule AshHq.Discord.Message do
|
|||
end
|
||||
end
|
||||
|
||||
attributes do
|
||||
integer_primary_key :id, generated?: false, writable?: true
|
||||
|
||||
attribute :author, :string do
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
attribute :content, :string
|
||||
attribute :content_html, :string
|
||||
|
||||
attribute :timestamp, :utc_datetime do
|
||||
allow_nil? false
|
||||
end
|
||||
end
|
||||
|
||||
relationships do
|
||||
belongs_to :thread, AshHq.Discord.Thread do
|
||||
attribute_type :integer
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
has_many :attachments, AshHq.Discord.Attachment
|
||||
has_many :reactions, AshHq.Discord.Reaction
|
||||
end
|
||||
|
||||
aggregates do
|
||||
first :channel_name, [:thread, :channel], :name
|
||||
first :thread_name, [:thread], :name
|
||||
|
|
|
@ -5,15 +5,6 @@ defmodule AshHq.Discord.Reaction do
|
|||
use Ash.Resource,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
postgres do
|
||||
table "discord_reactions"
|
||||
repo(AshHq.Repo)
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
end
|
||||
|
||||
attributes do
|
||||
uuid_primary_key :id
|
||||
|
||||
|
@ -26,14 +17,23 @@ defmodule AshHq.Discord.Reaction do
|
|||
end
|
||||
end
|
||||
|
||||
identities do
|
||||
identity :unique_message_emoji, [:emoji, :message_id]
|
||||
end
|
||||
|
||||
relationships do
|
||||
belongs_to :message, AshHq.Discord.Message do
|
||||
attribute_type :integer
|
||||
allow_nil? false
|
||||
end
|
||||
end
|
||||
|
||||
postgres do
|
||||
table "discord_reactions"
|
||||
repo AshHq.Repo
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
end
|
||||
|
||||
identities do
|
||||
identity :unique_message_emoji, [:emoji, :message_id]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,11 +3,6 @@ defmodule AshHq.Discord.Tag do
|
|||
use Ash.Resource,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
postgres do
|
||||
table "discord_tags"
|
||||
repo AshHq.Repo
|
||||
end
|
||||
|
||||
attributes do
|
||||
integer_primary_key :id, generated?: false, writable?: true
|
||||
|
||||
|
@ -16,6 +11,18 @@ defmodule AshHq.Discord.Tag do
|
|||
end
|
||||
end
|
||||
|
||||
relationships do
|
||||
belongs_to :channel, AshHq.Discord.Channel do
|
||||
attribute_type :integer
|
||||
attribute_writable? true
|
||||
end
|
||||
end
|
||||
|
||||
postgres do
|
||||
table "discord_tags"
|
||||
repo AshHq.Repo
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults [:create, :read, :update, :destroy]
|
||||
|
||||
|
@ -25,10 +32,6 @@ defmodule AshHq.Discord.Tag do
|
|||
end
|
||||
end
|
||||
|
||||
identities do
|
||||
identity :unique_name_per_channel, [:name, :channel_id]
|
||||
end
|
||||
|
||||
code_interface do
|
||||
define_for AshHq.Discord
|
||||
define :upsert, args: [:channel_id, :id, :name]
|
||||
|
@ -36,10 +39,7 @@ defmodule AshHq.Discord.Tag do
|
|||
define :destroy
|
||||
end
|
||||
|
||||
relationships do
|
||||
belongs_to :channel, AshHq.Discord.Channel do
|
||||
attribute_type :integer
|
||||
attribute_writable? true
|
||||
end
|
||||
identities do
|
||||
identity :unique_name_per_channel, [:name, :channel_id]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,39 @@ defmodule AshHq.Discord.Thread do
|
|||
|
||||
import Ecto.Query
|
||||
|
||||
attributes do
|
||||
integer_primary_key :id, generated?: false, writable?: true
|
||||
attribute :type, :integer
|
||||
|
||||
attribute :name, :string do
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
attribute :author, :string do
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
attribute :create_timestamp, :utc_datetime do
|
||||
allow_nil? false
|
||||
end
|
||||
end
|
||||
|
||||
relationships do
|
||||
has_many :messages, AshHq.Discord.Message
|
||||
|
||||
belongs_to :channel, AshHq.Discord.Channel do
|
||||
attribute_type :integer
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
end
|
||||
|
||||
many_to_many :tags, AshHq.Discord.Tag do
|
||||
through AshHq.Discord.ThreadTag
|
||||
source_attribute_on_join_resource :thread_id
|
||||
destination_attribute_on_join_resource :tag_id
|
||||
end
|
||||
end
|
||||
|
||||
postgres do
|
||||
table "discord_threads"
|
||||
repo AshHq.Repo
|
||||
|
@ -73,37 +106,4 @@ defmodule AshHq.Discord.Thread do
|
|||
define :by_id, action: :read, get_by: [:id]
|
||||
define :feed, args: [:channel]
|
||||
end
|
||||
|
||||
attributes do
|
||||
integer_primary_key :id, generated?: false, writable?: true
|
||||
attribute :type, :integer
|
||||
|
||||
attribute :name, :string do
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
attribute :author, :string do
|
||||
allow_nil? false
|
||||
end
|
||||
|
||||
attribute :create_timestamp, :utc_datetime do
|
||||
allow_nil? false
|
||||
end
|
||||
end
|
||||
|
||||
relationships do
|
||||
has_many :messages, AshHq.Discord.Message
|
||||
|
||||
belongs_to :channel, AshHq.Discord.Channel do
|
||||
attribute_type :integer
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
end
|
||||
|
||||
many_to_many :tags, AshHq.Discord.Tag do
|
||||
through AshHq.Discord.ThreadTag
|
||||
source_attribute_on_join_resource :thread_id
|
||||
destination_attribute_on_join_resource :tag_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,22 @@ defmodule AshHq.Discord.ThreadTag do
|
|||
use Ash.Resource,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
relationships do
|
||||
belongs_to :thread, AshHq.Discord.Thread do
|
||||
primary_key? true
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
attribute_type :integer
|
||||
end
|
||||
|
||||
belongs_to :tag, AshHq.Discord.Tag do
|
||||
primary_key? true
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
attribute_type :integer
|
||||
end
|
||||
end
|
||||
|
||||
postgres do
|
||||
table "discord_thread_tags"
|
||||
repo AshHq.Repo
|
||||
|
@ -20,20 +36,4 @@ defmodule AshHq.Discord.ThreadTag do
|
|||
define_for AshHq.Discord
|
||||
define :tag, args: [:thread_id, :tag_id]
|
||||
end
|
||||
|
||||
relationships do
|
||||
belongs_to :thread, AshHq.Discord.Thread do
|
||||
primary_key? true
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
attribute_type :integer
|
||||
end
|
||||
|
||||
belongs_to :tag, AshHq.Discord.Tag do
|
||||
primary_key? true
|
||||
allow_nil? false
|
||||
attribute_writable? true
|
||||
attribute_type :integer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -191,8 +191,7 @@ defmodule AshHq.Docs.Extensions.Search.Transformers.AddSearchStructure do
|
|||
end
|
||||
|
||||
defp add_match_rank_calculation(dsl_state, _config) do
|
||||
weight_content =
|
||||
AshHq.Docs.Extensions.Search.weight_content(dsl_state)
|
||||
weight_content = AshHq.Docs.Extensions.Search.weight_content(dsl_state)
|
||||
|
||||
dsl_state
|
||||
|> Transformer.add_entity(
|
||||
|
|
|
@ -59,7 +59,7 @@ defmodule AshHq.Docs.Dsl do
|
|||
:library_id
|
||||
]
|
||||
|
||||
weight_content 0.2
|
||||
weight_content(0.2)
|
||||
|
||||
sanitized_name_attribute :sanitized_path
|
||||
use_path_for_name? true
|
||||
|
|
|
@ -40,7 +40,7 @@ defmodule AshHq.Docs.Module do
|
|||
search do
|
||||
doc_attribute :doc
|
||||
|
||||
weight_content 0.5
|
||||
weight_content(0.5)
|
||||
|
||||
load_for_search [
|
||||
:version_name,
|
||||
|
|
|
@ -5,11 +5,6 @@ defmodule AshHq.MailingList.Email do
|
|||
data_layer: AshPostgres.DataLayer,
|
||||
notifiers: AshHq.MailingList.EmailNotifier
|
||||
|
||||
postgres do
|
||||
repo AshHq.Repo
|
||||
table "emails"
|
||||
end
|
||||
|
||||
attributes do
|
||||
uuid_primary_key :id
|
||||
|
||||
|
@ -20,6 +15,11 @@ defmodule AshHq.MailingList.Email do
|
|||
timestamps()
|
||||
end
|
||||
|
||||
postgres do
|
||||
repo AshHq.Repo
|
||||
table "emails"
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults [:create, :read]
|
||||
end
|
||||
|
|
|
@ -232,4 +232,4 @@ defmodule AshHq.Repo.Migrations.MigrateResources46 do
|
|||
) STORED;
|
||||
""")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue