feat: add task definition
This commit is contained in:
parent
0183675176
commit
ddf42409d5
6 changed files with 45 additions and 4 deletions
|
|
@ -10,6 +10,6 @@
|
|||
:phoenix
|
||||
],
|
||||
subdirectories: ["priv/*/migrations"],
|
||||
plugins: [Spark.Formatter, Phoenix.LiveView.HTMLFormatter],
|
||||
# plugins: [Spark.Formatter, Phoenix.LiveView.HTMLFormatter], # FIXME:seems broken
|
||||
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ config :spark,
|
|||
config :putzplan,
|
||||
ecto_repos: [Putzplan.Repo],
|
||||
generators: [timestamp_type: :utc_datetime],
|
||||
ash_domains: [Putzplan.Accounts]
|
||||
ash_domains: [Putzplan.Accounts, Putzplan.Tasks]
|
||||
|
||||
# Configures the endpoint
|
||||
config :putzplan, PutzplanWeb.Endpoint,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
buildInputs = with pkgs; [
|
||||
erlang_25
|
||||
beam.packages.erlang_25.elixir_1_18
|
||||
lexical
|
||||
beam.packages.erlang_25.elixir-ls
|
||||
next-ls
|
||||
]
|
||||
++ lib.optionals stdenv.isLinux [
|
||||
# For ExUnit Notifier on Linux.
|
||||
|
|
@ -46,7 +49,7 @@
|
|||
export PATH=$HEX_HOME/bin:$PATH
|
||||
|
||||
# enables history for IEx
|
||||
export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"$PWD/.erlang-history\"'"
|
||||
export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"$PWD/.nix/erlang-history\"'"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
7
lib/putzplan/tasks.ex
Normal file
7
lib/putzplan/tasks.ex
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
defmodule Putzplan.Tasks do
|
||||
use Ash.Domain
|
||||
|
||||
resources do
|
||||
resource Putzplan.Tasks.Definition
|
||||
end
|
||||
end
|
||||
31
lib/putzplan/tasks/definition.ex
Normal file
31
lib/putzplan/tasks/definition.ex
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
defmodule Putzplan.Tasks.Definition do
|
||||
# This turns this module into a resource
|
||||
use Ash.Resource, domain: Putzplan.Tasks
|
||||
|
||||
actions do
|
||||
# Use the default implementation of the :read action
|
||||
defaults [:read]
|
||||
|
||||
# and a create action, which we'll customize later
|
||||
create :create do
|
||||
accept [:description, :repetition_days]
|
||||
end
|
||||
end
|
||||
|
||||
# Attributes are the simple pieces of data that exist on your resource
|
||||
attributes do
|
||||
# Add an autogenerated UUID primary key called `:id`.
|
||||
uuid_primary_key :id
|
||||
|
||||
attribute :description, :string do
|
||||
allow_nil? false
|
||||
public? true
|
||||
end
|
||||
|
||||
attribute :repetition_days, :integer do
|
||||
allow_nil? false
|
||||
public? true
|
||||
constraints min: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -28,4 +28,4 @@ defmodule Putzplan.Repo.Migrations.InitializeAndAddAuthenticationResources do
|
|||
|
||||
drop table(:users)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue