Fix rubocop issues, introduce usage of frozen literal to improve performance
This commit is contained in:
parent
a91c3ef6ce
commit
fdc17bea58
96 changed files with 329 additions and 126 deletions
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::SalmonController < ApiController
|
||||
before_action :set_account
|
||||
respond_to :txt
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::SubscriptionsController < ApiController
|
||||
before_action :set_account
|
||||
respond_to :txt
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::AccountsController < ApiController
|
||||
before_action -> { doorkeeper_authorize! :read }, except: [:follow, :unfollow, :block, :unblock]
|
||||
before_action -> { doorkeeper_authorize! :follow }, only: [:follow, :unfollow, :block, :unblock]
|
||||
|
@ -20,7 +22,7 @@ class Api::V1::AccountsController < ApiController
|
|||
@accounts = results.map { |f| accounts[f.target_account_id] }
|
||||
|
||||
next_path = following_api_v1_account_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
||||
prev_path = following_api_v1_account_url(since_id: results.first.id) if results.size > 0
|
||||
prev_path = following_api_v1_account_url(since_id: results.first.id) unless results.empty?
|
||||
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
|
||||
|
@ -33,7 +35,7 @@ class Api::V1::AccountsController < ApiController
|
|||
@accounts = results.map { |f| accounts[f.account_id] }
|
||||
|
||||
next_path = followers_api_v1_account_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
||||
prev_path = followers_api_v1_account_url(since_id: results.first.id) if results.size > 0
|
||||
prev_path = followers_api_v1_account_url(since_id: results.first.id) unless results.empty?
|
||||
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
|
||||
|
@ -56,7 +58,7 @@ class Api::V1::AccountsController < ApiController
|
|||
set_maps(@statuses)
|
||||
|
||||
next_path = statuses_api_v1_account_url(max_id: @statuses.last.id) if @statuses.size == DEFAULT_STATUSES_LIMIT
|
||||
prev_path = statuses_api_v1_account_url(since_id: @statuses.first.id) if @statuses.size > 0
|
||||
prev_path = statuses_api_v1_account_url(since_id: @statuses.first.id) unless @statuses.empty?
|
||||
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::AppsController < ApiController
|
||||
respond_to :json
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::FollowsController < ApiController
|
||||
before_action -> { doorkeeper_authorize! :follow }
|
||||
before_action :require_user!
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::MediaController < ApiController
|
||||
before_action -> { doorkeeper_authorize! :write }
|
||||
before_action :require_user!
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::StatusesController < ApiController
|
||||
before_action -> { doorkeeper_authorize! :read }, except: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite]
|
||||
before_action -> { doorkeeper_authorize! :write }, only: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite]
|
||||
|
@ -10,7 +12,7 @@ class Api::V1::StatusesController < ApiController
|
|||
end
|
||||
|
||||
def context
|
||||
@context = OpenStruct.new({ ancestors: @status.ancestors, descendants: @status.descendants })
|
||||
@context = OpenStruct.new(ancestors: @status.ancestors, descendants: @status.descendants)
|
||||
set_maps([@status] + @context[:ancestors] + @context[:descendants])
|
||||
end
|
||||
|
||||
|
@ -20,7 +22,7 @@ class Api::V1::StatusesController < ApiController
|
|||
@accounts = results.map { |r| accounts[r.account_id] }
|
||||
|
||||
next_path = reblogged_by_api_v1_status_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
||||
prev_path = reblogged_by_api_v1_status_url(since_id: results.first.id) if results.size > 0
|
||||
prev_path = reblogged_by_api_v1_status_url(since_id: results.first.id) unless results.empty?
|
||||
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
|
||||
|
@ -33,7 +35,7 @@ class Api::V1::StatusesController < ApiController
|
|||
@accounts = results.map { |f| accounts[f.account_id] }
|
||||
|
||||
next_path = favourited_by_api_v1_status_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
||||
prev_path = favourited_by_api_v1_status_url(since_id: results.first.id) if results.size > 0
|
||||
prev_path = favourited_by_api_v1_status_url(since_id: results.first.id) unless results.empty?
|
||||
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::TimelinesController < ApiController
|
||||
before_action -> { doorkeeper_authorize! :read }
|
||||
before_action :require_user!, only: [:home, :mentions]
|
||||
|
@ -10,7 +12,7 @@ class Api::V1::TimelinesController < ApiController
|
|||
set_maps(@statuses)
|
||||
|
||||
next_path = api_v1_home_timeline_url(max_id: @statuses.last.id) if @statuses.size == DEFAULT_STATUSES_LIMIT
|
||||
prev_path = api_v1_home_timeline_url(since_id: @statuses.first.id) if @statuses.size > 0
|
||||
prev_path = api_v1_home_timeline_url(since_id: @statuses.first.id) unless @statuses.empty?
|
||||
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
|
||||
|
@ -23,7 +25,7 @@ class Api::V1::TimelinesController < ApiController
|
|||
set_maps(@statuses)
|
||||
|
||||
next_path = api_v1_mentions_timeline_url(max_id: @statuses.last.id) if @statuses.size == DEFAULT_STATUSES_LIMIT
|
||||
prev_path = api_v1_mentions_timeline_url(since_id: @statuses.first.id) if @statuses.size > 0
|
||||
prev_path = api_v1_mentions_timeline_url(since_id: @statuses.first.id) unless @statuses.empty?
|
||||
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
|
||||
|
@ -36,7 +38,7 @@ class Api::V1::TimelinesController < ApiController
|
|||
set_maps(@statuses)
|
||||
|
||||
next_path = api_v1_public_timeline_url(max_id: @statuses.last.id) if @statuses.size == DEFAULT_STATUSES_LIMIT
|
||||
prev_path = api_v1_public_timeline_url(since_id: @statuses.first.id) if @statuses.size > 0
|
||||
prev_path = api_v1_public_timeline_url(since_id: @statuses.first.id) unless @statuses.empty?
|
||||
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
|
||||
|
@ -50,7 +52,7 @@ class Api::V1::TimelinesController < ApiController
|
|||
set_maps(@statuses)
|
||||
|
||||
next_path = api_v1_hashtag_timeline_url(params[:id], max_id: @statuses.last.id) if @statuses.size == DEFAULT_STATUSES_LIMIT
|
||||
prev_path = api_v1_hashtag_timeline_url(params[:id], since_id: @statuses.first.id) if @statuses.size > 0
|
||||
prev_path = api_v1_hashtag_timeline_url(params[:id], since_id: @statuses.first.id) unless @statuses.empty?
|
||||
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue