add type specs and fix id issues
Some checks failed
Build and Publish / build-release (push) Failing after 37s
Some checks failed
Build and Publish / build-release (push) Failing after 37s
This commit is contained in:
@@ -10,6 +10,15 @@ defmodule WorkloadService.Aggregates.Task do
|
||||
end
|
||||
"""
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
id: WorkloadService.Aggregates.TaskId.t() | nil,
|
||||
application_id: WorkloadService.Aggregates.ApplicationId.t() | nil,
|
||||
task_info: map() | nil,
|
||||
submission: map() | nil,
|
||||
attachments: [String.t()],
|
||||
status: String.t() | nil
|
||||
}
|
||||
|
||||
@callback validate_submission(map()) :: :ok | {:error, term()}
|
||||
|
||||
defmacro __using__(opts) do
|
||||
@@ -55,8 +64,6 @@ defmodule WorkloadService.Aggregates.Task do
|
||||
def execute(%__MODULE__{status: status}, %SubmitResponse{} = cmd)
|
||||
when status in [nil, "created", "draft", "approved"] do
|
||||
with :ok <- validate_submission(cmd.submission) do
|
||||
new_status = if status == "approved", do: "draft", else: "draft"
|
||||
|
||||
%WorkloadService.Events.SubmissionUpdated{
|
||||
id: cmd.id,
|
||||
submission: cmd.submission,
|
||||
@@ -78,9 +85,9 @@ defmodule WorkloadService.Aggregates.Task do
|
||||
end
|
||||
|
||||
@impl Aggregate
|
||||
def execute(%__MODULE__{status: "approved"}, %CompleteTask{} = cmd) do
|
||||
def execute(%__MODULE__{status: "approved", id: id}, %CompleteTask{} = cmd) do
|
||||
%WorkloadService.Events.TaskCompleted{
|
||||
id: cmd.id,
|
||||
id: id,
|
||||
completed_by: cmd.completed_by
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user