@@ -57,6 +57,10 @@ def poll_location_hours(logger):
5757 str (row [1 ])[:- 3 ] if row [1 ] is not None else row [1 ],
5858 str (row [2 ])[:- 3 ] if row [1 ] is not None else row [2 ])
5959 for row in raw_redshift_data }
60+ redshift_earliest_open = min (
61+ hours [0 ] for hours in redshift_dict .values () if hours [0 ] is not None )
62+ redshift_latest_close = max (
63+ hours [1 ] for hours in redshift_dict .values () if hours [1 ] is not None )
6064
6165 logger .info ('Polling Refinery for regular location hours' )
6266 records = []
@@ -80,6 +84,18 @@ def poll_location_hours(logger):
8084 'regular_open' : api_hours ['open' ],
8185 'regular_close' : api_hours ['close' ],
8286 'date_of_change' : str (today )})
87+ if (api_hours ['open' ] is not None
88+ and api_hours ['open' ] < redshift_earliest_open ):
89+ logger .warning (
90+ ('Earliest opening time changed: was {old_open} and is '
91+ 'now {new_open}' ).format (old_open = redshift_earliest_open ,
92+ new_open = api_hours ['open' ]))
93+ if (api_hours ['close' ] is not None
94+ and api_hours ['close' ] > redshift_latest_close ):
95+ logger .warning (
96+ ('Latest closing time changed: was {old_close} and is now '
97+ '{new_close}' ).format (old_close = redshift_latest_close ,
98+ new_close = api_hours ['close' ]))
8399 encoded_records = avro_encoder .encode_batch (records )
84100 if os .environ .get ('IGNORE_KINESIS' , False ) != 'True' :
85101 kinesis_client .send_records (encoded_records )
0 commit comments