Skip to content

Commit

Permalink
fix filter
Browse files Browse the repository at this point in the history
  • Loading branch information
MadzMed committed Nov 29, 2024
1 parent 7341468 commit 8adae2f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
29 changes: 16 additions & 13 deletions datasources/connectors/open_agenda.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true
# typed: true

require 'async'
require 'sorbet-runtime'

require_relative 'connector'
Expand All @@ -19,7 +20,6 @@ def setup(kiba)
}))

agenda_uid = @settings['agenda_uid'].to_s
print(agenda_uid)
if agenda_uid.empty?
agendas = OpenAgendaSource.fetch('agendas', {
key: @settings['key']
Expand All @@ -36,20 +36,23 @@ def setup(kiba)
def _call(kiba, agenda_uid)
@settings['agenda_uid'] = agenda_uid
events = OpenAgendaSource.fetch("agendas/#{agenda_uid}/events", {
key: @settings['key']
key: @settings['key'],
'timings[gte]' => Date.today,
})

events.each do |event|
destination_id = "#{agenda_uid}-#{event['uid']}-#{event['title']['fr']}"
name = event['title']
events.map do |event|
Async do
destination_id = "#{agenda_uid}-#{event['uid']}-#{event['title']['fr']}"
name = event['title']

kiba.source(
OpenAgendaSource,
@job_id,
destination_id,
name,
OpenAgendaSource::Settings.from_hash(@settings.merge({ 'event_uid' => event['uid'].to_s, 'agenda_uid' => agenda_uid })),
)
end
kiba.source(
OpenAgendaSource,
@job_id,
destination_id,
name,
OpenAgendaSource::Settings.from_hash(@settings.merge({ 'event_uid' => event['uid'].to_s, 'agenda_uid' => agenda_uid })),
)
end
end.each(&:wait)
end
end
2 changes: 1 addition & 1 deletion datasources/sources/open_agenda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def self.fetch(path, query, key = 'events', size = 100, **kwargs)
end

def self.fetch_event(path, query)
url = T.let(build_url(path, query.merge({ 'timings[gte]' => Date.today })), T.nilable(String))
url = T.let(build_url(path, query), T.nilable(String))
response = HTTP.follow.get(url)
raise [url, response].inspect unless response.status.success?

Expand Down

0 comments on commit 8adae2f

Please sign in to comment.