scripts/base_script.rb
# Log the status of several records.
#
# @param table_name [Symbol] the name of the table.
# @param in_ids [Array/Integer] the ids of the records with the changed status.
# @param status [String] the status to be logged.
# @param comment [String] extra information about the status change.
# @param user_name [String] the current user's name.
Log the status of several records.
Log the status of several records .
def log_multiple_statuses(table_name, in_ids, status, comment: nil, user_name: nil) 
    ids = Array(in_ids)
    ids.each do |id|
      DB[Sequel[:audit][:current_statuses]].insert_conflict(target: %i[table_name row_data_id],
                                                            update: {
                                                              user_name: Sequel[:excluded][:user_name],
                                                              row_data_id: Sequel[:excluded][:row_data_id],
                                                              status: Sequel[:excluded][:status],
                                                              comment: Sequel[:excluded][:comment],
                                                              transaction_id: Sequel.function(:txid_current),
                                                              action_tstamp_tx: Time.now
                                                            }).insert(user_name: user_name,
                                                                      table_name: table_name.to_s,
                                                                      row_data_id: id,
                                                                      status: status.upcase,
                                                                      comment: comment)
    end
    items = []
    ids.each do |id|
      items << { user_name: user_name,
                 table_name: table_name.to_s,
                 row_data_id: id,
                 status: status.upcase,
                 comment: comment }
    end
    DB[Sequel[:audit][:status_logs]].multi_insert(items)
  end
def log_multiple_statuses ( table_name , in_ids , status , comment : nil , user_name : nil ) ids = Array ( in_ids ) ids . each do | id | DB [ Sequel [ :audit ] [ :current_statuses ] ] . insert_conflict ( target : %i[ table_name row_data_id ] , update : { user_name : Sequel [ :excluded ] [ :user_name ] , row_data_id : Sequel [ :excluded ] [ :row_data_id ] , status : Sequel [ :excluded ] [ :status ] , comment : Sequel [ :excluded ] [ :comment ] , transaction_id : Sequel . function ( :txid_current ) , action_tstamp_tx : Time . now } ) . insert ( user_name : user_name , table_name : table_name . to_s , row_data_id : id , status : status . upcase , comment : comment ) end items = [ ] ids . each do | id | items << { user_name : user_name , table_name : table_name . to_s , row_data_id : id , status : status . upcase , comment : comment } end DB [ Sequel [ :audit ] [ :status_logs ] ] . multi_insert ( items ) end
Log the status of several records.
Log the status of several records .
# rubocop:disable Metrics/AbcSize
table_name
the name of the table.
the name of the table .
in_ids
the ids of the records with the changed status.
the ids of the records with the changed status .
status
the status to be logged.
the status to be logged .
comment
extra information about the status change.
extra information about the status change .
user_name
the current user's name.
the current user ' s name .