<commit_before>module ConferenceManager
  module Support
    # This module provides support for Events organized by the ConferenceManger
    module Event
      
      CM_ATTRIBUTES = ["name", "cm_mode", "start_date", "end_date", "web_bw", "isabel_bw", "sip_interface", "httplivestreaming_bw", "permalink"]
      #in these arrays the number in kb is lower than in the comments because we pass the conference manager interface
      #only the video bandwidth, and the total is about 50kb lower
      WEB_BANDWIDTH = [100000, 200000, 400000] #equivalents: low (150K), medium (250K), high (450K)
      WEB_CODEC = ["H264","H264","H263"] #equivalents: low (h.264), medium (h.264), high (sorenson)
      RECORDING_BANDWIDTH = [0, 200000, 500000] #equivalents low (0) we don't use it, medium (250K), high (550K)
      RECORDING_CODEC = ["H264","H264","H264"] #equivalents: low (H.264), medium (h.264), high (h.264)  
      
      WEB_BW_HASH_FOR_DROP_DOWN = {"100000"=> ["Low (150K H.264)", "0"], "200000" => ["Medium (250K H.264)", "1"], "400000"=>["High (450K Sorenson)", "2"]}
      RECORDING_HASH_FOR_DROP_DOWN = {"0"=>["Medium (250K H.264)", "1"],"200000"=>["Medium (250K H.264)", "1"],"500000"=>["High (550K H.264)", "2"]}
      
      class << self
        def included(base)
          base.class_eval do

            validate_on_create do |event|
              if event.uses_conference_manager?
                cm_e =
                  ConferenceManager::Event.new(:name => event.name,
                                               :mode => event.cm_mode,
                                               :initDate => event.start_date,
                                               :endDate => event.end_date,
                                               :enable_web => "1",
                                               :enable_isabel => "1",
                                               :enable_sip => event.sip_interface?,
                                               :enable_httplivestreaming => "0",
                                               :isabel_bw => event.isabel_bw,
                                               :web_bw => WEB_BANDWIDTH[event.web_bw],
                                               :recording_bw => RECORDING_BANDWIDTH[event.recording_bw],
                                               :httplivestreaming_bw => WEB_BANDWIDTH[event.web_bw],
                                               :web_codec => WEB_CODEC[event.web_bw],
                                               :recording_codec => RECORDING_CODEC[event.recording_bw],
                                               :path => "attachments/conferences/#{event.permalink}")
                begin 
                  cm_e.save
                  event.cm_event_id = cm_e.id
                rescue StandardError => e
                  event.errors.add_to_base(e.to_s)
                end        
              end
            end
           
            validate_on_update do |event|              
              if event.uses_conference_manager? && (event.changed & CM_ATTRIBUTES).any? 
                new_params = { :name => event.name,
                               :mode => event.cm_mode,
                               :initDate => event.start_date,
                               :endDate => event.end_date,
                               :enable_web => "1",
                               :enable_isabel => "1",
                               :enable_sip => event.sip_interface?,<commit_msg>small change, when modifying past event<commit_after>module ConferenceManager
  module Support
    # This module provides support for Events organized by the ConferenceManger
    module Event
      
      CM_ATTRIBUTES = ["name", "cm_mode", "start_date", "end_date", "web_bw", "isabel_bw", "sip_interface", "httplivestreaming_bw", "permalink"]
      #in these arrays the number in kb is lower than in the comments because we pass the conference manager interface
      #only the video bandwidth, and the total is about 50kb lower
      WEB_BANDWIDTH = [100000, 200000, 400000] #equivalents: low (150K), medium (250K), high (450K)
      WEB_CODEC = ["H264","H264","H263"] #equivalents: low (h.264), medium (h.264), high (sorenson)
      RECORDING_BANDWIDTH = [0, 200000, 500000] #equivalents low (0) we don't use it, medium (250K), high (550K)
      RECORDING_CODEC = ["H264","H264","H264"] #equivalents: low (H.264), medium (h.264), high (h.264)  
      
      WEB_BW_HASH_FOR_DROP_DOWN = {"100000"=> ["Low (150K H.264)", "0"], "200000" => ["Medium (250K H.264)", "1"], "400000"=>["High (450K Sorenson)", "2"]}
      RECORDING_HASH_FOR_DROP_DOWN = {"0"=>["Medium (250K H.264)", "1"],"200000"=>["Medium (250K H.264)", "1"],"500000"=>["High (550K H.264)", "2"]}
      
      class << self
        def included(base)
          base.class_eval do

            validate_on_create do |event|
              if event.uses_conference_manager?
                cm_e =
                  ConferenceManager::Event.new(:name => event.name,
                                               :mode => event.cm_mode,
                                               :initDate => event.start_date,
                                               :endDate => event.end_date,
                                               :enable_web => "1",
                                               :enable_isabel => "1",
                                               :enable_sip => event.sip_interface?,
                                               :enable_httplivestreaming => "0",
                                               :isabel_bw => event.isabel_bw,
                                               :web_bw => WEB_BANDWIDTH[event.web_bw],
                                               :recording_bw => RECORDING_BANDWIDTH[event.recording_bw],
                                               :httplivestreaming_bw => WEB_BANDWIDTH[event.web_bw],
                                               :web_codec => WEB_CODEC[event.web_bw],
                                               :recording_codec => RECORDING_CODEC[event.recording_bw],
                                               :path => "attachments/conferences/#{event.permalink}")
                begin 
                  cm_e.save
                  event.cm_event_id = cm_e.id
                rescue StandardError => e
                  event.errors.add_to_base(e.to_s)
                end        
              end
            end
           
            validate_on_update do |event|              
              if !event.past? && event.uses_conference_manager? && (event.changed & CM_ATTRIBUTES).any? 
                new_params = { :name => event.name,
                               :mode => event.cm_mode,
                               :initDate => event.start_date,
                               :endDate => event.end_date,
                               :enable_web => "1",
                               :enable_isabel => "1",
                               :enable_sip => event.sip_interface?,
{'fraction_non_alphanumeric': 0.10858442296759523, 'fraction_numerical': 0.044627629334849345, 'mean_word_length': 1.3339966832504146, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 56, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '125511', 'n_tokens_mistral': 2081, 'n_tokens_neox': 1832, 'n_words': 409}