Sha256: ee8e722f2137f64b3bc1c64217c3d25efeebaffc885916675836a36ef213f3b8
Contents?: true
Size: 930 Bytes
Versions: 10
Compression:
Stored size: 930 Bytes
Contents
class EventsController < ApplicationController MAX_BATCH_SIZE = 100 before_action :authorize before_action :contacts, only: %i[index] def index end def not_shown_count render json: { count: Event.where('created_at > ?', params[:time_mark].to_datetime).count } end private def authorize unless authorized? redirect_to login_path and return unless Token.any? session['tokens'] = Token.instance.attributes end session['tokens'] = Services::Authorization::Tokens::Refresh.new(tokens: session['tokens'], request: request).call Services::Authorization::AuthorizeHubspot.new(tokens: session['tokens']).call end def contacts contact_id_batches = Event.all.map(&:object_id).uniq.each_slice(MAX_BATCH_SIZE).to_a @contacts = contact_id_batches.each_with_object([]) do |batch, memo| memo.concat Services::Hubspot::Contacts::GetBatch.new(batch).call end end end
Version data entries
10 entries across 10 versions & 1 rubygems