<commit_before>require "rubygems"
require "bundler"
require "pg"
require "rack"
require "rack/contrib"
Bundler.require :default, (ENV["RACK_ENV"] || "development").to_sym

class Application < Sinatra::Base

  configure :production, :development do
    enable :logging
  end

  def initialize
    connection_hash = {
      host: ENV['ANALYSIS_DB_HOST'],
      dbname: ENV['ANALYSIS_DB_DBNAME'],
      user: ENV['ANALYSIS_DB_USER'],
      password: ENV['<PASSWORD>']
    }
    @db = PG.connect(connection_hash)
  end

  post "/segment" do
    logger.info params
    begin
      @db.exec("INSERT INTO events (          \
                              event_name,     \
                              occurred_at,    \
                              user_id,        \
                              details         \
                ) VALUES (                    \
                    #{params[:event]},       \
                    #{params[:timestamp]},   \
                    #{params[:userId]},      \
                    #{params[:properties]}   \
                )")
    rescue PG::Error => err
      logger.error "Problem inserting an event (#{params[:event]}) at #{params[:timestamp]}"
    end
  end<commit_msg>what's the matter pg?<commit_after>require "rubygems"
require "bundler"
require "pg"
require "rack"
require "rack/contrib"
Bundler.require :default, (ENV["RACK_ENV"] || "development").to_sym

class Application < Sinatra::Base

  configure :production, :development do
    enable :logging
  end

  def initialize
    connection_hash = {
      host: ENV['ANALYSIS_DB_HOST'],
      dbname: ENV['ANALYSIS_DB_DBNAME'],
      user: ENV['ANALYSIS_DB_USER'],
      password: ENV['<PASSWORD>']
    }
    @db = PG.connect(connection_hash)
  end

  post "/segment" do
    logger.info params
    begin
      @db.exec("INSERT INTO events (          \
                              event_name,     \
                              occurred_at,    \
                              user_id,        \
                              details         \
                ) VALUES (                    \
                    #{params[:event]},       \
                    #{params[:timestamp]},   \
                    #{params[:userId]},      \
                    #{params[:properties]}   \
                )")
    rescue PG::Error => err
      logger.error "Problem inserting an event (#{params[:event]}) at #{params[:timestamp]}"
      logger.error err.message
      logger.error err.inspect
    end
  end
{'fraction_non_alphanumeric': 0.11708099438652766, 'fraction_numerical': 0.0, 'mean_word_length': 1.495, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1146348', 'n_tokens_mistral': 724, 'n_tokens_neox': 694, 'n_words': 144}