Skip to content

Commit

Permalink
APPEALS-65696 sequence id hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
breedbah committed Nov 25, 2024
1 parent c9e911f commit ca90f9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/models/hearings/transcription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Transcription < CaseflowRecord
belongs_to :transcription_contractor
has_many :transcription_files, class_name: "TranscriptionFile"
belongs_to :transcription_package, foreign_key: :task_number, primary_key: :task_number
before_create :sequence_task_id
before_validation :sequence_task_id

validates :hearing_type, inclusion: { in: %w[Hearing LegacyHearing] }
validates :hearing, presence: true
Expand Down
16 changes: 7 additions & 9 deletions app/services/hearings/transcription_sequence_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,30 @@
# This file defines a Ruby function that mimics the functionality of the PL/SQL trigger.
# It's not a direct translation, but provides a similar behavior for managing task IDs.

# Define a constant to represent the system generated tag.
SYSTEM_GEN_TAG = User.system_user.id

# Define a class to represent the transcriptions table.
class Hearings::TranscriptionSequenceId
attr_accessor :created_by_id, :task_id
attr_accessor :created_by_id, :task_id, :transcription_status

# Initialize a new transcription object.
def initialize(created_by_id, task_id = nil)
@created_by_id = created_by_id
@task_id = task_id
@transcription_status = "unassigned"
end

# Simulate the trigger execution.
def before_insert_on_transcriptions(transcription)
# Set the transcription status to "unassigned"
transcription.transcription_status = "unassigned"
# Call the trigger function to update the task ID.
trg_myseq(transcription)
end

# Define a function to simulate the trigger behavior.
def trg_myseq(transcription)
# Check if the transcription was created by the system.
if transcription.created_by_id == SYSTEM_GEN_TAG
# Generate a new task ID if the transcription was created by the system.
transcription.task_id = next_task_id
end
# Generate a new task ID if the transcription was created by the system.
transcription.task_id = next_task_id
# Return the updated transcription object.
transcription.task_id
end
Expand All @@ -40,7 +38,7 @@ def next_task_id
# This implementation simply returns an incremented value.
@task_id ||= 0
# Switch this value back to 1 after testing
@task_id += 5000
@task_id += 1

@task_id
end
Expand Down

0 comments on commit ca90f9a

Please sign in to comment.