Run rubocop on all files
This commit is contained in:
@@ -2,12 +2,11 @@ module Admin
|
||||
module Actions
|
||||
module AutoTagging
|
||||
class Create < Action
|
||||
|
||||
include Deps["commands.auto_tagging.create",
|
||||
"views.auto_tagging.index",
|
||||
"validation.contracts.auto_tagging_contract",
|
||||
auto_tag: "commands.auto_tagging.tag",
|
||||
new_view: "views.auto_tagging.new"]
|
||||
"views.auto_tagging.index",
|
||||
"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]
|
||||
@@ -16,16 +15,16 @@ module Admin
|
||||
tag_now = req.params[:tag_now]
|
||||
|
||||
validation = auto_tagging_contract.call(title_contains: title_contains,
|
||||
body_contains: body_contains,
|
||||
tag_id: tag_id)
|
||||
body_contains: body_contains,
|
||||
tag_id: tag_id)
|
||||
|
||||
if validation.success?
|
||||
result = create.(title_contains: title_contains,
|
||||
body_contains: body_contains,
|
||||
tag_id: tag_id)
|
||||
result = create.call(title_contains: title_contains,
|
||||
body_contains: body_contains,
|
||||
tag_id: tag_id)
|
||||
|
||||
if result.success? && tag_now
|
||||
auto_tag.(auto_tag_id: result.value!)
|
||||
auto_tag.call(auto_tag_id: result.value!)
|
||||
end
|
||||
|
||||
res.render index
|
||||
@@ -36,4 +35,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module AutoTagging
|
||||
class Delete < Action
|
||||
|
||||
include Deps["repos.auto_tagging_repo"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module AutoTagging
|
||||
class Index < Action
|
||||
|
||||
include Deps["views.auto_tagging.index"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module AutoTagging
|
||||
class New < Action
|
||||
|
||||
include Deps[new_view: "views.auto_tagging.new"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Archive < Action
|
||||
|
||||
include Deps["repos.bookmark_repo"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -13,4 +12,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,19 +2,18 @@ module Admin
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Cache < Action
|
||||
|
||||
include Deps["commands.bookmarks.cache"]
|
||||
|
||||
def handle(req, res)
|
||||
bookmark_id = req.params[:id]
|
||||
|
||||
if cache.(bookmark_id: bookmark_id).success?
|
||||
res.body = "Success"
|
||||
res.body = if cache.call(bookmark_id: bookmark_id).success?
|
||||
"Success"
|
||||
else
|
||||
res.body = "Failed"
|
||||
"Failed"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -4,7 +4,6 @@ module Admin
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Clean < Action
|
||||
|
||||
def handle(req, res)
|
||||
Que.connection = Adamantium::Container["persistence.db"]
|
||||
|
||||
@@ -19,4 +18,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Delete < Action
|
||||
|
||||
include Deps["repos.bookmark_repo", "repos.post_tag_repo"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -14,4 +13,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Index < Action
|
||||
|
||||
include Deps["views.bookmarks.index"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -1,12 +1,11 @@
|
||||
module Admin
|
||||
module Actions
|
||||
class Index < Action
|
||||
|
||||
include Deps["views.index"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module MergeTags
|
||||
class Index < Action
|
||||
|
||||
include Deps["views.merge_tags.index"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,14 +2,13 @@ module Admin
|
||||
module Actions
|
||||
module MergeTags
|
||||
class Merge < Action
|
||||
|
||||
include Deps["commands.merge_tags.merge"]
|
||||
|
||||
def handle(req, res)
|
||||
target_id = req.params[:target_id]
|
||||
source_id = req.params[:source_id]
|
||||
|
||||
result = merge.(target_id: target_id, source_id: source_id)
|
||||
result = merge.call(target_id: target_id, source_id: source_id)
|
||||
|
||||
if result.success?
|
||||
res.redirect_to "/admin/tags/merge"
|
||||
@@ -21,4 +20,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module MergeTags
|
||||
class New < Action
|
||||
|
||||
include Deps[new_view: "views.merge_tags.new"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Photos
|
||||
class Index < Action
|
||||
|
||||
include Deps["views.photos.index"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Posts
|
||||
class Archive < Action
|
||||
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -13,4 +12,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Posts
|
||||
class Delete < Action
|
||||
|
||||
include Deps["repos.post_repo", "repos.post_tag_repo"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -14,4 +13,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Posts
|
||||
class Index < Action
|
||||
|
||||
include Deps["views.posts.index"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Posts
|
||||
class Publish < Action
|
||||
|
||||
include Deps["repos.post_repo"]
|
||||
def handle(req, res)
|
||||
post_id = req.params[:id]
|
||||
@@ -12,4 +11,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Tags
|
||||
class Delete < Action
|
||||
|
||||
include Deps["repos.post_tag_repo", "repos.tag_repo"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -14,4 +13,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Actions
|
||||
module Tags
|
||||
class Index < Action
|
||||
|
||||
include Deps["views.tags.index"]
|
||||
|
||||
def handle(req, res)
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -4,7 +4,6 @@ module Admin
|
||||
module Actions
|
||||
module Trips
|
||||
class AddPost < Admin::Action
|
||||
|
||||
include Deps["commands.trips.add_post"]
|
||||
|
||||
def handle(req, res)
|
||||
|
@@ -4,7 +4,6 @@ module Admin
|
||||
module Actions
|
||||
module Trips
|
||||
class Create < Admin::Action
|
||||
|
||||
include Deps["commands.trips.create"]
|
||||
|
||||
def handle(req, res)
|
||||
|
@@ -4,7 +4,6 @@ module Admin
|
||||
module Actions
|
||||
module Trips
|
||||
class Show < Admin::Action
|
||||
|
||||
include Deps["views.trips.show"]
|
||||
|
||||
def handle(req, res)
|
||||
|
@@ -4,7 +4,6 @@ module Admin
|
||||
module Actions
|
||||
module Trips
|
||||
class Update < Admin::Action
|
||||
|
||||
include Deps["commands.trips.update"]
|
||||
|
||||
def handle(req, res)
|
||||
|
@@ -9,8 +9,8 @@ module Admin
|
||||
Failure() if !title_contains.empty? && !body_contains.empty?
|
||||
|
||||
result = auto_tagging_repo.create(title_contains: title_contains,
|
||||
body_contains: body_contains,
|
||||
tag_id: tag_id)
|
||||
body_contains: body_contains,
|
||||
tag_id: tag_id)
|
||||
|
||||
Success(result.id)
|
||||
end
|
||||
|
@@ -7,10 +7,10 @@ module Admin
|
||||
|
||||
def call(auto_tag_id: nil)
|
||||
auto_taggings = if auto_tag_id
|
||||
auto_tagging_repo.find(auto_tag_id)
|
||||
else
|
||||
auto_tagging_repo.all
|
||||
end
|
||||
auto_tagging_repo.find(auto_tag_id)
|
||||
else
|
||||
auto_tagging_repo.all
|
||||
end
|
||||
|
||||
auto_taggings.each do |auto_tagging|
|
||||
posts = auto_tagging.title_only? ?
|
||||
@@ -19,7 +19,7 @@ module Admin
|
||||
|
||||
posts.each do |post|
|
||||
post_repo.tag_post(post_id: post.id,
|
||||
tag_id: auto_tagging.tag_id)
|
||||
tag_id: auto_tagging.tag_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -8,7 +8,7 @@ module Admin
|
||||
include Dry::Monads[:result]
|
||||
include Deps["repos.bookmark_repo"]
|
||||
|
||||
def call(bookmark_id: )
|
||||
def call(bookmark_id:)
|
||||
bookmark = bookmark_repo.fetch(id: bookmark_id)
|
||||
bookmark.url
|
||||
|
||||
|
@@ -4,7 +4,6 @@ module Admin
|
||||
module Commands
|
||||
module Movies
|
||||
class Create
|
||||
|
||||
include Deps["repos.movie_repo"]
|
||||
|
||||
def call(movie)
|
||||
@@ -20,8 +19,7 @@ module Admin
|
||||
|
||||
repo.create(movie)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -32,4 +32,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -16,4 +16,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -4,13 +4,12 @@ module Admin
|
||||
module Repos
|
||||
class PostRepo < Adamantium::Repo[:posts]
|
||||
def tag_post(post_id:, tag_id:)
|
||||
|
||||
return if posts
|
||||
.post_tags
|
||||
.where(
|
||||
post_id: post_id,
|
||||
tag_id: tag_id
|
||||
).count > 0
|
||||
.post_tags
|
||||
.where(
|
||||
post_id: post_id,
|
||||
tag_id: tag_id
|
||||
).count > 0
|
||||
|
||||
posts
|
||||
.post_tags
|
||||
@@ -64,4 +63,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -1,7 +1,6 @@
|
||||
module Admin
|
||||
module Repos
|
||||
class PostTagRepo < Adamantium::Repo[:post_tags]
|
||||
|
||||
def merge_tags(target_id:, source_id:)
|
||||
post_tags.where(tag_id: source_id).update(tag_id: target_id)
|
||||
end
|
||||
|
@@ -6,6 +6,7 @@ module Admin
|
||||
.order(Sequel.function(:lower, :label))
|
||||
.to_a
|
||||
end
|
||||
|
||||
def list_with_posts
|
||||
tags
|
||||
.combine(:posts)
|
||||
|
@@ -10,4 +10,4 @@ module Admin
|
||||
attribute :label, Types::Coercible::String
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -3,4 +3,4 @@ module Admin
|
||||
config.layouts_dir = "layouts"
|
||||
config.paths = "slices/admin/templates"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Views
|
||||
module AutoTagging
|
||||
class Index < Admin::View
|
||||
|
||||
include Deps["repos.auto_tagging_repo"]
|
||||
|
||||
expose :auto_taggings do
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Views
|
||||
module AutoTagging
|
||||
class New < Admin::View
|
||||
|
||||
include Deps["repos.tag_repo"]
|
||||
|
||||
expose :tags do
|
||||
@@ -15,4 +14,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -4,7 +4,6 @@ module Admin
|
||||
module Views
|
||||
module Bookmarks
|
||||
class Index < Admin::View
|
||||
|
||||
include Deps["repos.bookmark_repo"]
|
||||
|
||||
expose :published_bookmarks do |bookmarks|
|
||||
@@ -16,7 +15,7 @@ module Admin
|
||||
end
|
||||
|
||||
expose :bookmarks do
|
||||
bookmark_repo.list.partition{|p| p.published_at }
|
||||
bookmark_repo.list.partition { |p| p.published_at }
|
||||
end
|
||||
|
||||
expose :running_jobs do
|
||||
@@ -26,4 +25,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -1,7 +1,6 @@
|
||||
module Admin
|
||||
module Views
|
||||
class Index < Admin::View
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Views
|
||||
module MergeTags
|
||||
class Index < Admin::View
|
||||
|
||||
include Deps["repos.tag_repo"]
|
||||
|
||||
expose :tags do
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Views
|
||||
module MergeTags
|
||||
class New < Admin::View
|
||||
|
||||
include Deps["repos.tag_repo"]
|
||||
|
||||
expose :tag do |id:|
|
||||
@@ -15,4 +14,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Views
|
||||
module Photos
|
||||
class Index < Admin::View
|
||||
|
||||
MEDIA_DIR = "public/media/".freeze
|
||||
|
||||
expose :photos_buckets do
|
||||
@@ -13,4 +12,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Views
|
||||
module Posts
|
||||
class Index < Admin::View
|
||||
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :published_posts do |posts|
|
||||
@@ -14,9 +13,9 @@ module Admin
|
||||
end
|
||||
|
||||
expose :posts do
|
||||
post_repo.list.partition{|p| p.published_at }
|
||||
post_repo.list.partition { |p| p.published_at }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Views
|
||||
module Tags
|
||||
class Index < Admin::View
|
||||
|
||||
include Deps["repos.tag_repo"]
|
||||
|
||||
expose :tags do
|
||||
@@ -10,13 +9,13 @@ module Admin
|
||||
end
|
||||
|
||||
expose :unused_tags do |tags|
|
||||
tags.partition {|t| t.posts.count == 0}.first
|
||||
tags.partition { |t| t.posts.count == 0 }.first
|
||||
end
|
||||
|
||||
expose :used_tags do |tags|
|
||||
tags.partition {|t| t.posts.count == 0}.last
|
||||
tags.partition { |t| t.posts.count == 0 }.last
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Views
|
||||
module Trips
|
||||
class Index < Admin::View
|
||||
|
||||
include Deps["repos.trip_repo"]
|
||||
|
||||
expose :trips do
|
||||
@@ -11,4 +10,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -8,4 +8,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -2,7 +2,6 @@ module Admin
|
||||
module Views
|
||||
module Trips
|
||||
class Show < Admin::View
|
||||
|
||||
include Deps["repos.trip_repo", "repos.post_repo"]
|
||||
|
||||
expose :trip do |id:|
|
||||
@@ -15,4 +14,4 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user