Skip to content

Commit

Permalink
Merge pull request #1072 from DaanVanVugt/bugfix/lcrdm_scraper_next_year
Browse files Browse the repository at this point in the history
lcrdm choose next year if event longer than 2 weeks ago
  • Loading branch information
fbacall authored Dec 20, 2024
2 parents bcb7db9 + db121fd commit ad42e4a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/ingestors/lcrdm_ingestor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ 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])
if split_time_str[1].split(' ').length == 1
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')
Expand Down

0 comments on commit ad42e4a

Please sign in to comment.