Module: Eco::API::MicroCases::People::Manage::Cache
- Included in:
- Eco::API::MicroCases::People::Manage
- Defined in:
- lib/eco/api/microcases/people/manage/cache.rb
Instance Method Summary collapse
-
#people_cache(filename = enviro.config.people.cache, modifier: [:save]) ⇒ Eco::API::Organization::People
Helper to locally cache the people manager (download via API).
Instance Method Details
#people_cache(filename = enviro.config.people.cache, modifier: [:save]) ⇒ Eco::API::Organization::People
Helper to locally cache the people manager (download via API).
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eco/api/microcases/people/manage/cache.rb', line 10 def people_cache(filename = enviro.config.people.cache, modifier: [:save]) modifier = [modifier].flatten log(:info) { 'Going to get all the people via API' } start = Time.now session.batch.get_people.tap do |people| secs = (Time.now - start).round(3) cnt = people.count per_sec = (cnt.to_f / secs).round(2) log(:info) { "Loaded #{cnt} people in #{secs} seconds (#{per_sec} people/sec)" } if modifier.include?(:save) file = file_manager.save_json(people, filename, :timestamp) log(:info) { "#{people.length} people loaded and saved locally to #{file}." } end end.then do |people| Eco::API::Organization::People.new(people) end end |