Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Apr 17, 2024
1 parent eacc1d2 commit 9e438af
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
3 changes: 2 additions & 1 deletion app/controllers/api/v1/queries/agent_q_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AgentQController < Queries::ApplicationController
before_action :check_query, only: [ :fetch ]
@browser = nil

# rubocop:disable Metrics/AbcSize
def fetch
api_key = nil
if @current_user.api_keys.empty?
Expand Down Expand Up @@ -88,8 +89,8 @@ def fetch
else
render json: { agentq_error: 'boom', counter: counter }, status: :internal_server_error
end
# Close the browser
end
# rubocop:enable Metrics/AbcSize
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/queries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create
if @query.save
@query.insert_at(params[:position].to_i) if params[:position]
# next line I think deals with positioning
@case.save # Having this line made inserting a new case trigger a bunch of updates which was slow.
@case.save # Having this line made inserting a new case trigger a bunch of updates which was slow.

Analytics::Tracker.track_query_created_event current_user, @query

Expand Down Expand Up @@ -86,7 +86,7 @@ def destroy

# Make sure queries have the right `arranged_next` and `arranged_at`
# values after the query has been removed
@case.rearrange_queries # super slow with lots of queires
@case.rearrange_queries # super slow with lots of queires
@case.save

head :no_content
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/core_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class CoreController < ApplicationController
before_action :populate_from_params, except: :new
skip_before_action :check_for_announcement

#def require_login
# def require_login
# @current_user = User.find(3)
#end
# end

# Spiking out can we make an API public?
def authenticate_api!
Expand Down
23 changes: 15 additions & 8 deletions app/jobs/run_case_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ class RunCaseJob < ApplicationJob
queue_as :single
sidekiq_options retry: 0

@@browser = nil
@browser = nil

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/PerceivedComplexity
def perform user, kase
api_key = nil
if user.api_keys.empty?
Expand All @@ -20,24 +24,23 @@ def perform user, kase
retries = 3

begin
if @@browser.nil?
if @browser.nil?
puts 'creating Ferrum Browser'
# Launch Ferrum browser

@@browser = Ferrum::Browser.new({
@browser = Ferrum::Browser.new({
process_timeout: 5, headless: 'new',
window_size: [ 1280, 800 ],
browser_options: { 'no-sandbox': nil },
timeout: 60,
pending_connection_errors: false,
js_errors: false,
browser_options: { 'no-sandbox': nil }
js_errors: false

})
end

# @browser.headers.set({ 'Authorization' => "Bearer #{api_key.token_digest}" })
page = @@browser.create_page
page = @browser.create_page
page.headers.set({ 'Authorization' => "Bearer #{api_key.token_digest}" })

kase.queries.each do |query|
Expand Down Expand Up @@ -92,9 +95,13 @@ def perform user, kase
ensure
# @browser.close if @browser # not yet released
puts 'about to reset browser'
@@browser.reset
# @@browser.quit
@browser.reset
# @browser.quit
# puts "browser quit"
end
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/PerceivedComplexity
end
4 changes: 4 additions & 0 deletions app/jobs/run_case_job2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class RunCaseJob2 < ApplicationJob
queue_as :single
sidekiq_options retry: 0

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
def perform user, kase
api_key = nil
if user.api_keys.empty?
Expand Down Expand Up @@ -37,4 +39,6 @@ def perform user, kase
end
end
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/AbcSize
end

0 comments on commit 9e438af

Please sign in to comment.