Sha256: 2d96001bc0edef94580780f7fee166e836c937554037eccb254e52c2bd2a986d

Contents?: true

Size: 911 Bytes

Versions: 16

Compression:

Stored size: 911 Bytes

Contents

module Eco
  module API
    class MicroCases
      # Helper to locally cache the people manager.
      # @param filename [String] the name of the file where the data should be cached.
      # @return [Eco::API::Organization::People] the `People` object with the data.
      def people_cache(filename = enviro.config.people.cache)
        logger.info("Going to get all the people via API")

        start = Time.now
        people = session.batch.get_people
        secs    = Time.now - start
        cnt     = people.count
        per_sec = (cnt.to_f / secs).floor
        logger.info("Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)")

        file   = file_manager.save_json(people, filename, :timestamp)
        logger.info("#{people.length} people loaded and saved locally to #{file}.")
        Eco::API::Organization::People.new(people)
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
eco-helpers-2.0.16 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.15 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.14 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.13 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.12 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.11 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.10 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.9 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.8 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.7 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.6 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.5 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.4 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.3 lib/eco/api/microcases/people_cache.rb
eco-helpers-2.0.2 lib/eco/api/microcases/people_cache.rb
eco-helpers-1.5.15 lib/eco/api/microcases/people_cache.rb