app/controllers/api/v2/remote_edit_controller.rb
# POST #update_reservation
#     { u: <user.email>, t: <auth_token>,
#       b: <badge_id>, e: <meeting_event_id>, time: <incremental_timing_text> (can be nil),
#       on: <is_doing_this>, skip: <is_not_coming>, ok: <has_confirmed>, n: <notes> }
#
# Creates or updates a specific tuple/set of reservations, storing the resulting SQL
# text as a serialized DB-diff into the dedicated row (free_text_1) of AppParameter.
# The actual row ID for the serialization of the DB-diff SQL text depends upon
# the current_user.id (100_000 + user.id).
# The action will involve either a MeetingEventReservation or a MeetingRelayReservation
# depending by the type of the specified MeetingEvent ID.
# Header rows (MeetingReservation) are also handled.
#
# @see MeetingReservationUpdater for more info.
#
# At the end of the update process a SendDbDiffJob will be invoked to be run after
# a few minutes.
# The delay in minutes should be chosen as "enough" to collect multiple DB updates
# at once, in order to avoid sending too many DB-diff files to the same SysOp e-mail.
#
# === Parameters:
# - "e"     => MeetingEvent id (required, key#2)
# - "b"     => Badge id (required, key#1)
# - "time"  => incremental timing value as text (e.g.: "1'15\"00"); can be nil when deleting rows
# - "skip"  => 'is_not_coming' ON=1 / OFF=0 <default> as smallint char digit; when '1' any detail row will be deleted
# - "on"    => 'is_doing_this' ON=1 / OFF=0 <default> as smallint char digit
# - "ok"    => 'has_confirmed' ON=1 / OFF=0 <default> as smallint char digit
# - "rn"    => MeetingRelayReservation notes text
#              (relay specific, using the format "<relay name>';'<relay_order>")
# - "n"     => MeetingReservation notes text (common HEADER)
# - "l"     => Request href/document.location
#
# === Returns:
#
# A JSON response (either :success or :error).
#


Creates or updates a specific tuple/set of reservations, storing the resulting SQL
text as a serialized DB-diff into the dedicated row (free_text_1) of AppParameter.
The actual row ID for the serialization of the DB-diff SQL text depends upon
the current_user.id (100_000 + user.id).
The action will involve either a MeetingEventReservation or a MeetingRelayReservation
depending by the type of the specified MeetingEvent ID.
Header rows (MeetingReservation) are also handled.
Creates or updates a specific tuple / set of reservations storing the resulting SQL text as a serialized DB - diff into the dedicated row ( free_text_1 ) of AppParameter . The actual row ID for the serialization of the DB - diff SQL text depends upon the current_user . id ( 100_000 + user . id ) . The action will involve either a MeetingEventReservation or a MeetingRelayReservation depending by the type of the specified MeetingEvent ID . Header rows ( MeetingReservation ) are also handled .
def update_reservation
    puts "\r\n--- #update_reservation: ---\r\nPARAMS: #{ params.inspect }"
    meeting_id    = params['m']
    badge_id      = params['b']
    event_id      = params['e']
    is_not_coming = params['skip'].present? ? !!(params['skip'].to_s =~ /1|true|t/i) : nil
    is_doing_this = params['on'].present? ? !!(params['on'].to_s =~ /1|true|t/i) : nil
    has_confirmed = params['ok'].present? ? !!(params['ok'].to_s =~ /1|true|t/i) : nil
    timing_text   = params['time'].to_s
    notes         = params['n']
    rel_notes     = params['rn']
    req_url       = params['l'].to_s
    unless meeting_id.present? && badge_id.present? 
      render( status: 400, json: { result: "error", message: I18n.t("api.errors.invalid_request") } ) and return
      return
    end
    updater = MeetingReservationUpdater.new( current_user )
    result  = updater.process!( meeting_id, badge_id, event_id, is_doing_this,
                                is_not_coming, has_confirmed, timing_text, notes, rel_notes )
    if result.nil?                                  
      render( status: 400, json: { result: "error", message: I18n.t("api.errors.unable_to_find_or_create_data_row") } ) and return
    elsif result                                    
      serialize_into_app_parameters!( updater, I18n.t('meeting_reservation.manage_button_title').upcase, req_url )
      SendDbDiffJob.set( queue: :edit, wait: WAIT_MINS_BEFORE_JOB_CREATE ).perform_later
    end
    render status: 200, json: { result: "ok" }
  end
def update_reservation puts "\r\n--- #update_reservation: ---\r\nPARAMS: #{ params.inspect }" meeting_id = params [ 'm' ] badge_id = params [ 'b' ] event_id = params [ 'e' ] is_not_coming = params [ 'skip' ] . present? ? ! ! ( params [ 'skip' ] . to_s =~ / 1|true|t /i ) : nil is_doing_this = params [ 'on' ] . present? ? ! ! ( params [ 'on' ] . to_s =~ / 1|true|t /i ) : nil has_confirmed = params [ 'ok' ] . present? ? ! ! ( params [ 'ok' ] . to_s =~ / 1|true|t /i ) : nil timing_text = params [ 'time' ] . to_s notes = params [ 'n' ] rel_notes = params [ 'rn' ] req_url = params [ 'l' ] . to_s unless meeting_id . present? && badge_id . present? render ( status : 400 , json : { result : "error" , message : I18n . t ( "api.errors.invalid_request" ) } ) and return return end updater = MeetingReservationUpdater . new ( current_user ) result = updater . process! ( meeting_id , badge_id , event_id , is_doing_this , is_not_coming , has_confirmed , timing_text , notes , rel_notes ) if result . nil? render ( status : 400 , json : { result : "error" , message : I18n . t ( "api.errors.unable_to_find_or_create_data_row" ) } ) and return elsif result serialize_into_app_parameters! ( updater , I18n . t ( 'meeting_reservation.manage_button_title' ) . upcase , req_url ) SendDbDiffJob . set ( queue : :edit , wait : WAIT_MINS_BEFORE_JOB_CREATE ) . perform_later end render status : 200 , json : { result : "ok" } end
POST #update_reservation
{ u: <user.email>, t: <auth_token>,
b: <badge_id>, e: <meeting_event_id>, time: <incremental_timing_text> (can be nil),
on: <is_doing_this>, skip: <is_not_coming>, ok: <has_confirmed>, n: <notes> }
POST #update_reservation { u : <user . email > t : <auth_token > b : <badge_id > e : <meeting_event_id > time : <incremental_timing_text > ( can be nil ) on : <is_doing_this > skip : <is_not_coming > ok : <has_confirmed > n : <notes > }
# DEBUG # Fetch params # Nothing to do, bail out: # DEBUG #      puts "update_reservation: meeting_id or badge_id MISSING" # --- ERROR during CREATE/UPDATE --- # DEBUG #      puts "update_reservation: result is nil" # --- CREATE / UPDATE / DELETE performed --- # Add SQL text to AppParameter: # Launch delayed Job to send the DB-diff to the SysOp using the remote-editing # dedicated named queue ('edit'): #    else # (no operations for result false => DELETE skipped => no SQL edits)
see
MeetingReservationUpdater for more info. At the end of the update process a SendDbDiffJob will be invoked to be run after a few minutes. The delay in minutes should be chosen as "enough" to collect multiple DB updates at once, in order to avoid sending too many DB-diff files to the same SysOp e-mail. === Parameters: - "e" => MeetingEvent id (required, key#2) - "b" => Badge id (required, key#1) - "time" => incremental timing value as text ; can be nil when deleting rows - "skip" => 'is_not_coming' ON=1 / OFF=0  as smallint char digit; when '1' any detail row will be deleted - "on" => 'is_doing_this' ON=1 / OFF=0  as smallint char digit - "ok" => 'has_confirmed' ON=1 / OFF=0  as smallint char digit - "rn" => MeetingRelayReservation notes text (relay specific, using the format "';'") - "n" => MeetingReservation notes text (common HEADER) - "l" => Request href/document.location === Returns: A JSON response (either :success or :error).
MeetingReservationUpdater for more info . At the end of the update process a SendDbDiffJob will be invoked to be run after a few minutes . The delay in minutes should be chosen as " enough " to collect multiple DB updates at once in order to avoid sending too many DB - diff files to the same SysOp e - mail . === Parameters : - " e " = > MeetingEvent id ( required key#2 ) - " b " = > Badge id ( required key#1 ) - " time " = > incremental timing value as text ; can be nil when deleting rows - " skip " = > ' is_not_coming ' ON = 1 / OFF = 0 as smallint char digit ; when ' 1 ' any detail row will be deleted - " on " = > ' is_doing_this ' ON = 1 / OFF = 0 as smallint char digit - " ok " = > ' has_confirmed ' ON = 1 / OFF = 0 as smallint char digit - " rn " = > MeetingRelayReservation notes text ( relay specific using the format " ' ; ' " ) - " n " = > MeetingReservation notes text ( common HEADER ) - " l " = > Request href / document . location === Returns : A JSON response ( either : success or : error ) .