From c1d756ec6f1ed5502a2e3b8cc5a0f84f2e8a4214 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Tue, 31 Oct 2023 08:17:10 +1100 Subject: [PATCH] Standard rb fixes --- app/action.rb | 2 +- app/decorators/bookmarks/decorator.rb | 2 -- app/queries/posts/top_tracks.rb | 2 +- lib/adamantium/persistence/relations/posts.rb | 8 ++++---- script/test | 1 + slices/admin/actions/posts/add_syndication_source.rb | 5 ++--- slices/admin/actions/posts/update.rb | 2 +- slices/admin/commands/posts/update.rb | 4 ++-- slices/admin/views/photos/index.rb | 2 +- 9 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/action.rb b/app/action.rb index 9134438..5315d5b 100644 --- a/app/action.rb +++ b/app/action.rb @@ -82,7 +82,7 @@ module Adamantium halt 401 unless (decoded_response.include? :scope) && (decoded_response.include? :me) - decoded_response[:scope].gsub(/post/, "create").split.map(&:to_sym) + decoded_response[:scope].gsub("post", "create").split.map(&:to_sym) end end end diff --git a/app/decorators/bookmarks/decorator.rb b/app/decorators/bookmarks/decorator.rb index 68a2eb5..92353f8 100644 --- a/app/decorators/bookmarks/decorator.rb +++ b/app/decorators/bookmarks/decorator.rb @@ -36,8 +36,6 @@ module Adamantium code = url.scan(pattern).flatten.first if code "
" - else - nil end end end diff --git a/app/queries/posts/top_tracks.rb b/app/queries/posts/top_tracks.rb index 9f6f005..b1e31f5 100644 --- a/app/queries/posts/top_tracks.rb +++ b/app/queries/posts/top_tracks.rb @@ -33,7 +33,7 @@ module Adamantium end ENV["TZ"] = nil - top_track_repo.for_post(id: post.id) + top_track_repo.for_post(id: post.id) end end end diff --git a/lib/adamantium/persistence/relations/posts.rb b/lib/adamantium/persistence/relations/posts.rb index c27ec77..9ee2cf7 100644 --- a/lib/adamantium/persistence/relations/posts.rb +++ b/lib/adamantium/persistence/relations/posts.rb @@ -23,13 +23,13 @@ module Adamantium end def weekly - ref = post_tags.where(:tag_id => "70").select(:post_id).dataset - where(:id => ref) + ref = post_tags.where(tag_id: "70").select(:post_id).dataset + where(id: ref) end def non_weekly - ref = post_tags.where(:tag_id => "70").select(:post_id).dataset - exclude(:id => ref) + ref = post_tags.where(tag_id: "70").select(:post_id).dataset + exclude(id: ref) end def published_between(start_date, end_date) diff --git a/script/test b/script/test index 11f4d2e..e072c29 100755 --- a/script/test +++ b/script/test @@ -17,3 +17,4 @@ if [ -n "$1" ]; then else bundle exec rake spec fi + diff --git a/slices/admin/actions/posts/add_syndication_source.rb b/slices/admin/actions/posts/add_syndication_source.rb index 381f192..c50e817 100644 --- a/slices/admin/actions/posts/add_syndication_source.rb +++ b/slices/admin/actions/posts/add_syndication_source.rb @@ -8,9 +8,8 @@ module Admin def handle(req, res) add_syndication_source.call(post_id: req.params[:id], - source_name: req.params[:syndication_source_name], - source_url: req.params[:syndication_source_url] - ) + source_name: req.params[:syndication_source_name], + source_url: req.params[:syndication_source_url]) res.status = 201 res.headers["HX-Refresh"] = true diff --git a/slices/admin/actions/posts/update.rb b/slices/admin/actions/posts/update.rb index 042b4a7..69701c0 100644 --- a/slices/admin/actions/posts/update.rb +++ b/slices/admin/actions/posts/update.rb @@ -5,7 +5,7 @@ module Admin include Deps["commands.posts.update"] def handle(req, res) - update.(params: req.params) + update.call(params: req.params) res.redirect "/admin/posts/#{req.params[:id]}" end end diff --git a/slices/admin/commands/posts/update.rb b/slices/admin/commands/posts/update.rb index e6b0dcf..76c0a18 100644 --- a/slices/admin/commands/posts/update.rb +++ b/slices/admin/commands/posts/update.rb @@ -3,8 +3,8 @@ module Admin module Posts class Update include Deps[ - "repos.post_repo", - "renderers.markdown" + "repos.post_repo", + "renderers.markdown" ] def call(params:) diff --git a/slices/admin/views/photos/index.rb b/slices/admin/views/photos/index.rb index 334b8bf..a431eb7 100644 --- a/slices/admin/views/photos/index.rb +++ b/slices/admin/views/photos/index.rb @@ -7,7 +7,7 @@ module Admin expose :photos_buckets do |available_paths| available_paths.each_with_object({}) do |root, memo| - memo[root.gsub(MEDIA_DIR, "")] = Dir["#{root}/**"].sort {|a,b| File.ctime(b) <=> File.ctime(a) } + memo[root.gsub(MEDIA_DIR, "")] = Dir["#{root}/**"].sort { |a, b| File.ctime(b) <=> File.ctime(a) } end end