app/models/concerns/checkable.rb
# Fetches scrobbles from the service between the +start_time+ and +end_time+, handling the expected errors by storing
# them in the returned object. Yields to the block to handle the batch if given.
#
#   scrobbler.collect_scrobbles(2.hours.ago, Time.current) { |batch| puts 'yay' if batch.success? }
#
# @param start_time [Time] the beginning of the time range from which to fetch data
# @param end_time [Time] the end of the time rante from which to fetch data
# @return [ScrobbleBatch] the list of scrobbles fetched from the service, with additional metadata
# @yield [batch] provides an interface for handling the generated batch of scrobbles. Useful for collecting multiple
#   batches from a service
Fetches scrobbles from the service between the +start_time+ and +end_time+, handling the expected errors by storing
them in the returned object. Yields to the block to handle the batch if given.


Fetches scrobbles from the service between the + start_time + and + end_time + handling the expected errors by storing them in the returned object . Yields to the block to handle the batch if given .
def collect_scrobbles(start_time, end_time)
    scrobbles, error =
      begin
        [fetch_and_format_scrobbles(start_time, end_time), nil]
      rescue Errors::ServiceError => e
        [[], e]
      end
    batch = ScrobbleBatch.new(scrobbles, source: self, start_time: start_time, end_time: end_time, error: error)
    yield(batch) if block_given?
    batch
  end
def collect_scrobbles ( start_time , end_time ) scrobbles , error = begin [ fetch_and_format_scrobbles ( start_time , end_time ) , nil ] rescue Errors :: ServiceError => e [ [ ] , e ] end batch = ScrobbleBatch . new ( scrobbles , source : self , start_time : start_time , end_time : end_time , error : error ) yield ( batch ) if block_given? batch end
Fetches scrobbles from the service between the +start_time+ and +end_time+, handling the expected errors by storing
them in the returned object.
Fetches scrobbles from the service between the + start_time + and + end_time + handling the expected errors by storing them in the returned object .
the list of scrobbles fetched from the service, with additional metadata
the list of scrobbles fetched from the service with additional metadata
ScrobbleBatch
start_time
the beginning of the time range from which to fetch data
the beginning of the time range from which to fetch data
end_time
the end of the time rante from which to fetch data
the end of the time rante from which to fetch data
]
<not_specific>
provides an interface for handling the generated batch of scrobbles. Useful for collecting multiple batches from a service
provides an interface for handling the generated batch of scrobbles . Useful for collecting multiple batches from a service