From db121fd3a899f20de22cf96667ff18cd33105ed7 Mon Sep 17 00:00:00 2001 From: Mike Sanders Date: Fri, 20 Dec 2024 13:25:18 +0100 Subject: [PATCH] lcrdm choose next year if event longer than 2 weeks ago --- lib/ingestors/lcrdm_ingestor.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ingestors/lcrdm_ingestor.rb b/lib/ingestors/lcrdm_ingestor.rb index 6fee83549..c975285ae 100644 --- a/lib/ingestors/lcrdm_ingestor.rb +++ b/lib/ingestors/lcrdm_ingestor.rb @@ -35,7 +35,6 @@ def process_lcrdm(url) event.title = h2.text.strip event.url = h2.get_attribute('href').strip event.venue = event_data.css('ul.post-item__meta svg.icon--marker')[0]&.parent&.text&.strip - time_str = event_data.css('ul.post-item__meta svg.icon--calendar')[0]&.parent&.text&.strip split_time_str = time_str.split(' — ') event.start = Time.zone.parse(split_time_str[0]) @@ -43,9 +42,13 @@ def process_lcrdm(url) a = split_time_str[0].split(' ') b = split_time_str[1] event.end = Time.zone.parse([a[0], a[1], b].join(' ')) - elsif split_time_str[1].split(' ').length == 3 + elsif [2, 3].include?(split_time_str[1].split(' ').length) event.end = Time.zone.parse(split_time_str[1]) end + if event.start < Time.zone.now - 2.weeks + event.start = event.start.change(year: Time.now.year + 1) + event.end = event.end.change(year: Time.now.year + 1) + end event_page2 = Nokogiri::HTML5.parse(open_url(event.url.to_s, raise: true)).css('main#main-content div.entry__inner') sleep(1) unless Rails.env.test? and File.exist?('test/vcr_cassettes/ingestors/lcrdm.yml')