Sha256: 01eee3a9c62dce96a599e7b302272ed5a6dceea0515888c3af6f7f6140f5df08

Contents?: true

Size: 784 Bytes

Versions: 2

Compression:

Stored size: 784 Bytes

Contents

require "enju_search_log/engine"
require "enju_search_log/user"

module EnjuSearchLog
  def save_search_history(query, offset = 0, total = 0, user = nil)
    return unless user.try(:save_search_history)
    if configatron.write_search_log_to_file
      write_search_log(query, total, user)
    else
      history = SearchHistory.new(:query => query, :start_record => offset + 1, :maximum_records => nil, :number_of_records => total)
      history.user = user
      history.save
    end
  end

  def write_search_log(query, total, user)
    if user
      username = user.username if user.save_search_history
    end
    SEARCH_LOGGER.info "#{Time.zone.now}\t#{query}\t#{total}\t#{username}\t#{params[:format]}"
  end
end

ActiveRecord::Base.send :include, EnjuSearchLog::SearchLogUser

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
enju_search_log-0.1.0.pre lib/enju_search_log.rb
enju_search_log-0.0.7 lib/enju_search_log.rb