Skip to content

Commit

Permalink
🤖
Browse files Browse the repository at this point in the history
  • Loading branch information
bonflintstone committed Oct 28, 2024
1 parent 275968c commit ac1a4f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Event < ApplicationRecord
ORGANIZATIONS = ["Leokino", "Theater Praesent", "Treibhaus", "Die Bäckerei", "Haus der Musik"]
ORGANIZATIONS = [ "Leokino", "Theater Praesent", "Treibhaus", "Die Bäckerei", "Haus der Musik" ]

validates :name, :location, :datetime, :link, presence: true
validates :organization, inclusion: { in: ORGANIZATIONS }
Expand Down
16 changes: 8 additions & 8 deletions app/services/fetch_haus_der_musik.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ def self.call
response = HTTParty.get("https://www.haus-der-musik-innsbruck.at/kalender/")
document = Nokogiri::HTML(response.body)

document.css('.EventList article').map do |event_row|
datetime = event_row.css('time').attr('datetime')&.then(&Time.method(:parse))
next unless datetime.present?
document.css(".EventList article").map do |event_row|
datetime = event_row.css("time").attr("datetime")&.then(&Time.method(:parse))
next unless datetime.present?

name = event_row.css('h2.title-5').text.strip
description = event_row.css('.info span:first-child').text
location = event_row.css('.stats .stat:nth-child(2) strong').text
link = 'https://www.haus-der-musik-innsbruck.at' + event_row.css('.info a').attr('href').value
name = event_row.css("h2.title-5").text.strip
description = event_row.css(".info span:first-child").text
location = event_row.css(".stats .stat:nth-child(2) strong").text
link = "https://www.haus-der-musik-innsbruck.at" + event_row.css(".info a").attr("href").value

Event.create(datetime:, location:, name:, link:, description:, organization: 'Haus der Musik').errors
Event.create(datetime:, location:, name:, link:, description:, organization: "Haus der Musik").errors
end
end
end
2 changes: 1 addition & 1 deletion app/services/fetch_leokino.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.call
location = movie_row.css("td:first-child h3:last-of-type").text.strip
name = movie_row.css("td:last-child h3 a").children.map(&:text).join(" - ")
link = "https://leokino.at" + movie_row.css("td:last-child h3 a").attr("href").value
description = movie_row.css("td:last-child p:last-child").text.sub('[ mehr ]', '').strip
description = movie_row.css("td:last-child p:last-child").text.sub("[ mehr ]", "").strip

Event.create(datetime:, location:, name:, link:, description:, organization: "Leokino")
end
Expand Down

0 comments on commit ac1a4f1

Please sign in to comment.