Method: Blend::Client::JuiceClient#activities_stats

Defined in:
lib/blend/client/juice_client.rb

#activities_stats(activities, after, before) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/blend/client/juice_client.rb', line 221

def activities_stats( activities, after, before )
  stats = { type: {}, 
            actors_activites: {}, 
            activities: activities, 
            after: after, 
            before: before, 
            active_tickets: {},
            closed_tickets: {}}

  activities.each do |x|
    x['happened_at'] = Time.parse x['happened_at']
  end.sort do |a,b|
    a['happened_at'] <=> b['happened_at']
  end.each do |a|
    actor = a['actor_identifier']
    type = a['activity_type']
    stats[:type][type] ||= []
    stats[:type][type] << a

    if( !(type =~ /^juice/) && !(type =~ /tweet/) )
      stats[:actors_activites][type] ||= {}
      stats[:actors_activites][type][actor] ||= []
      stats[:actors_activites][type][actor] << a
    end
  end

  stats
end