-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2023 Clivern. All rights reserved. | ||
# Use of this source code is governed by the MIT | ||
# license that can be found in the LICENSE file. | ||
|
||
defmodule Lynx.Module.TaskModule do | ||
@moduledoc """ | ||
User Module | ||
""" | ||
|
||
alias Lynx.Context.TaskContext | ||
|
||
@doc """ | ||
Get task by UUID | ||
""" | ||
def get_task_by_uuid(uuid) do | ||
case TaskContext.get_task_by_uuid(uuid) do | ||
nil -> | ||
{:not_found, "Task with UUID #{uuid} not found"} | ||
|
||
task -> | ||
{:ok, task} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2023 Clivern. All rights reserved. | ||
# Use of this source code is governed by the MIT | ||
# license that can be found in the LICENSE file. | ||
|
||
defmodule LynxWeb.TaskView do | ||
use LynxWeb, :view | ||
|
||
# Render task | ||
def render("index.json", %{task: task}) do | ||
render_task(task) | ||
end | ||
|
||
# Render errors | ||
def render("error.json", %{message: message}) do | ||
%{errorMessage: message} | ||
end | ||
|
||
# Format task | ||
defp render_task(task) do | ||
%{ | ||
id: task.uuid, | ||
status: task.status, | ||
runAt: task.run_at, | ||
createdAt: task.inserted_at, | ||
updatedAt: task.updated_at | ||
} | ||
end | ||
end |