Class: Fedipub::Maintenance::HostsUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/fedipub/maintenance/hosts_updater.rb

Class Method Summary collapse

Class Method Details

.run(cache_interval: nil) ⇒ Object

Update information for all known hosts, and complete if some are missing



6
7
8
9
10
11
12
13
14
15
# File 'lib/fedipub/maintenance/hosts_updater.rb', line 6

def run(cache_interval: nil)
  cache_interval ||= Fedipub::Configuration.remote_entities_cache_duration

  domains = Fedipub::Actor.distant.distinct(:server).pluck(:server) + Fedipub::Host.pluck(:domain)
  domains.uniq!

  domains.each do |domain|
    Fedipub::Host.create_or_update domain, min_update_interval: cache_interval
  end
end