Better handling of works in OpenData without date

This commit is contained in:
Lucas Verney 2018-11-29 12:06:26 +01:00
parent 9ce1e4c6a4
commit 82e414a63d

View File

@ -586,8 +586,16 @@ def process_opendata(name, data, report_type=REPORT_TYPE):
# Check that the work is currently being done # Check that the work is currently being done
now = arrow.now('Europe/Paris') now = arrow.now('Europe/Paris')
if fields['date_debut']:
start_date = arrow.get(fields['date_debut']) start_date = arrow.get(fields['date_debut'])
else:
# Defaults to now if start date is unknown
start_date = arrow.get(now)
if fields['date_fin']:
end_date = arrow.get(fields['date_fin']) end_date = arrow.get(fields['date_fin'])
else:
# Defaults to in a week if start date is unknown
end_date = arrow.get(now).shift(days=+7)
if not (start_date < now < end_date): if not (start_date < now < end_date):
logging.info( logging.info(
'Ignoring record %s, work not currently in progress.', 'Ignoring record %s, work not currently in progress.',
@ -648,8 +656,9 @@ def process_opendata(name, data, report_type=REPORT_TYPE):
item['recordid'] item['recordid']
) )
continue continue
# Check no similar reports is nearby # Check no similar reports is within the area of the report, up
overlap_area = transform(project, position).buffer( # to the report distance.
overlap_area = transform(project, geo_shape).buffer(
MIN_DISTANCE_REPORT_DETAILS MIN_DISTANCE_REPORT_DETAILS
) )
is_already_inserted = False is_already_inserted = False