From 4b4cc09586f4c3e3b2270566dd250e5df71004d5 Mon Sep 17 00:00:00 2001 From: breedbah <123968373+breedbah@users.noreply.github.com> Date: Mon, 25 Nov 2024 16:00:34 -0500 Subject: [PATCH] APPEALS-65696 sequence id hotfix --- app/models/hearings/transcription.rb | 2 +- .../hearings/transcription_sequence_id.rb | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/models/hearings/transcription.rb b/app/models/hearings/transcription.rb index e58ef0b78ff..5d61788afd6 100644 --- a/app/models/hearings/transcription.rb +++ b/app/models/hearings/transcription.rb @@ -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 diff --git a/app/services/hearings/transcription_sequence_id.rb b/app/services/hearings/transcription_sequence_id.rb index 8b2d37d13a9..8246df6d226 100644 --- a/app/services/hearings/transcription_sequence_id.rb +++ b/app/services/hearings/transcription_sequence_id.rb @@ -3,21 +3,21 @@ # 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 @@ -25,10 +25,8 @@ def before_insert_on_transcriptions(transcription) # 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 @@ -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