Created
September 18, 2017 21:21
-
-
Save debborafernandess/e9f8fc01f25d30c2b7cb1fbed960b116 to your computer and use it in GitHub Desktop.
Rodar o relatorio diario para as unidades que nao rodaram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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