Clean up auto tagging

This commit is contained in:
2023-05-06 20:27:11 +10:00
parent 9f8359d782
commit 0c74055e27
7 changed files with 52 additions and 11 deletions

View File

@@ -5,22 +5,32 @@ module Admin
include Deps["commands.auto_tagging.create",
"views.auto_tagging.index",
auto_tag: "commands.auto_tagging.tag"]
"validation.contracts.auto_tagging_contract",
auto_tag: "commands.auto_tagging.tag",
new_view: "views.auto_tagging.new"]
def handle(req, res)
title_contains = req.params[:title_contains]
body_contains = req.params[:body_contains]
tag_id = req.params[:tag_id]
result = create.(title_contains: title_contains,
body_contains: body_contains,
tag_id: tag_id)
validation = auto_tagging_contract.call(title_contains: title_contains,
body_contains: body_contains,
tag_id: tag_id)
if result.success?
auto_tag.(auto_tag_id: result.value!)
if validation.success?
result = create.(title_contains: title_contains,
body_contains: body_contains,
tag_id: tag_id)
if result.success?
auto_tag.(auto_tag_id: result.value!)
end
res.render index
end
res.render index
res.render new_view, errors: validation.errors
end
end
end

View File

@@ -6,7 +6,7 @@ module Admin
include Deps[new_view: "views.auto_tagging.new"]
def handle(req, res)
res.render new_view
res.render new_view, errors: {}
end
end
end