Skip to content

Commit

Permalink
Format and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hulloitskai committed Sep 14, 2024
1 parent f8d25be commit 16104b7
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 34 deletions.
1 change: 0 additions & 1 deletion app/models/input_field_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def self.from(model_errors)
sig { returns(T::Hash[String, String]) }
def to_h
super do |error|
error = T.let(error, InputFieldError)
[error.field, error.message]
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# rubocop:disable Layout/LineLength
# frozen_string_literal: true

class RecreateGoodJobCronIndexesWithConditional < ActiveRecord::Migration[7.0]
Expand All @@ -6,38 +7,50 @@ class RecreateGoodJobCronIndexesWithConditional < ActiveRecord::Migration[7.0]
def change
reversible do |dir|
dir.up do
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond)
add_index :good_jobs, [:cron_key, :created_at], where: "(cron_key IS NOT NULL)",
unless connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_cron_key_and_created_at_cond)
add_index :good_jobs, %i[cron_key created_at], where: "(cron_key IS NOT NULL)",
name: :index_good_jobs_on_cron_key_and_created_at_cond, algorithm: :concurrently
end
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond)
add_index :good_jobs, [:cron_key, :cron_at], where: "(cron_key IS NOT NULL)", unique: true,
unless connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_cron_key_and_cron_at_cond)
add_index :good_jobs, %i[cron_key cron_at], where: "(cron_key IS NOT NULL)", unique: true,
name: :index_good_jobs_on_cron_key_and_cron_at_cond, algorithm: :concurrently
end

if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at)
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at
if connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_cron_key_and_created_at)
remove_index :good_jobs,
name: :index_good_jobs_on_cron_key_and_created_at
end
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at)
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at
if connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_cron_key_and_cron_at)
remove_index :good_jobs,
name: :index_good_jobs_on_cron_key_and_cron_at
end
end

dir.down do
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at)
add_index :good_jobs, [:cron_key, :created_at],
unless connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_cron_key_and_created_at)
add_index :good_jobs, %i[cron_key created_at],
name: :index_good_jobs_on_cron_key_and_created_at, algorithm: :concurrently
end
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at)
add_index :good_jobs, [:cron_key, :cron_at], unique: true,
unless connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_cron_key_and_cron_at)
add_index :good_jobs, %i[cron_key cron_at], unique: true,
name: :index_good_jobs_on_cron_key_and_cron_at, algorithm: :concurrently
end

if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond)
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at_cond
end
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond)
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at_cond
if connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_cron_key_and_created_at_cond)
remove_index :good_jobs,
name: :index_good_jobs_on_cron_key_and_created_at_cond
end
if connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_cron_key_and_cron_at_cond)
remove_index :good_jobs,
name: :index_good_jobs_on_cron_key_and_cron_at_cond
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion db/migrate/20240811043451_create_good_job_labels_index.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# rubocop:disable Layout/LineLength
# frozen_string_literal: true

class CreateGoodJobLabelsIndex < ActiveRecord::Migration[7.0]
Expand All @@ -6,7 +7,8 @@ class CreateGoodJobLabelsIndex < ActiveRecord::Migration[7.0]
def change
reversible do |dir|
dir.up do
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels)
unless connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_labels)
add_index :good_jobs, :labels, using: :gin, where: "(labels IS NOT NULL)",
name: :index_good_jobs_on_labels, algorithm: :concurrently
end
Expand Down
9 changes: 6 additions & 3 deletions db/migrate/20240811043452_remove_good_job_active_id_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ class RemoveGoodJobActiveIdIndex < ActiveRecord::Migration[7.0]
def change
reversible do |dir|
dir.up do
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id)
if connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_active_job_id)
remove_index :good_jobs, name: :index_good_jobs_on_active_job_id
end
end

dir.down do
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id)
add_index :good_jobs, :active_job_id, name: :index_good_jobs_on_active_job_id
unless connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_active_job_id)
add_index :good_jobs, :active_job_id,
name: :index_good_jobs_on_active_job_id
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# rubocop:disable Layout/LineLength
# frozen_string_literal: true

class CreateIndexGoodJobJobsForCandidateLookup < ActiveRecord::Migration[7.0]
Expand All @@ -8,11 +9,12 @@ def change
dir.up do
# Ensure this incremental update migration is idempotent
# with monolithic install migration.
return if connection.index_name_exists?(:good_jobs, :index_good_job_jobs_for_candidate_lookup)
return if connection.index_name_exists?(:good_jobs,
:index_good_job_jobs_for_candidate_lookup)
end
end

add_index :good_jobs, [:priority, :created_at], order: { priority: "ASC NULLS LAST", created_at: :asc },
add_index :good_jobs, %i[priority created_at], order: { priority: "ASC NULLS LAST", created_at: :asc },
where: "finished_at IS NULL", name: :index_good_job_jobs_for_candidate_lookup,
algorithm: :concurrently
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def change
dir.up do
# Ensure this incremental update migration is idempotent
# with monolithic install migration.
return if connection.column_exists?(:good_job_executions, :error_backtrace)
return if connection.column_exists?(:good_job_executions,
:error_backtrace)
end
end

Expand Down
29 changes: 21 additions & 8 deletions db/migrate/20240811043456_create_good_job_process_lock_indexes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# rubocop:disable Layout/LineLength
# frozen_string_literal: true

class CreateGoodJobProcessLockIndexes < ActiveRecord::Migration[7.0]
Expand All @@ -6,32 +7,44 @@ class CreateGoodJobProcessLockIndexes < ActiveRecord::Migration[7.0]
def change
reversible do |dir|
dir.up do
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked)
add_index :good_jobs, [:priority, :scheduled_at],
unless connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_priority_scheduled_at_unfinished_unlocked)
add_index :good_jobs, %i[priority scheduled_at],
order: { priority: "ASC NULLS LAST", scheduled_at: :asc },
where: "finished_at IS NULL AND locked_by_id IS NULL",
name: :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked,
algorithm: :concurrently
end

unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_locked_by_id)
unless connection.index_name_exists?(:good_jobs,
:index_good_jobs_on_locked_by_id)
add_index :good_jobs, :locked_by_id,
where: "locked_by_id IS NOT NULL",
name: :index_good_jobs_on_locked_by_id,
algorithm: :concurrently
end

unless connection.index_name_exists?(:good_job_executions, :index_good_job_executions_on_process_id_and_created_at)
add_index :good_job_executions, [:process_id, :created_at],
unless connection.index_name_exists?(:good_job_executions,
:index_good_job_executions_on_process_id_and_created_at)
add_index :good_job_executions, %i[process_id created_at],
name: :index_good_job_executions_on_process_id_and_created_at,
algorithm: :concurrently
end
end

dir.down do
remove_index(:good_jobs, name: :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked) if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked)
remove_index(:good_jobs, name: :index_good_jobs_on_locked_by_id) if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_locked_by_id)
remove_index(:good_job_executions, name: :index_good_job_executions_on_process_id_and_created_at) if connection.index_name_exists?(:good_job_executions, :index_good_job_executions_on_process_id_and_created_at)
remove_index(:good_jobs,
name: :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked) if connection.index_name_exists?(
:good_jobs, :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked
)
remove_index(:good_jobs,
name: :index_good_jobs_on_locked_by_id) if connection.index_name_exists?(
:good_jobs, :index_good_jobs_on_locked_by_id
)
remove_index(:good_job_executions,
name: :index_good_job_executions_on_process_id_and_created_at) if connection.index_name_exists?(
:good_job_executions, :index_good_job_executions_on_process_id_and_created_at
)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion sorbet/rbi/gems/[email protected]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 16104b7

Please sign in to comment.