Skip to content

Instantly share code, notes, and snippets.

@debborafernandess
Created September 18, 2017 21:21
Show Gist options
  • Save debborafernandess/e9f8fc01f25d30c2b7cb1fbed960b116 to your computer and use it in GitHub Desktop.
Save debborafernandess/e9f8fc01f25d30c2b7cb1fbed960b116 to your computer and use it in GitHub Desktop.
Rodar o relatorio diario para as unidades que nao rodaram
str_date = '2017-09-16'
locations_cached_ids = DailyReportCache.where('reference_date = ?', str_date).map &:location_id
active_locations_ids = Location.active.map &:id
location_ids = active_locations_ids - locations_cached_ids
location_ids.each do |location_id|
parsed_date = Date.parse(str_date).strftime('%d/%m/%Y')
DailyReport::Main.new(
start_date: parsed_date,
location_id: location_id
).execute
end
# confirmar se a quantidade de cache criada corresponde as locations ativas
DailyReportCache.where(reference_date: str_date).count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment