File tree Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,16 @@ def initialize(config = Timeframe::Application.config.local)
3
3
@config = config
4
4
end
5
5
6
- def prepare_response ( response )
6
+ def fetch
7
7
start_time = ( Time . now - 1 . day ) . utc . iso8601
8
8
end_time = ( Time . now + 5 . days ) . utc . iso8601
9
9
10
10
out = [ ]
11
11
12
- response . each do |calendar |
12
+ Timeframe ::Application . config . local [ "calendars" ] . each do |calendar |
13
+ next unless calendar [ "entity_id" ] . present?
14
+
13
15
res = HTTParty . get ( "#{ url } /#{ calendar [ "entity_id" ] } ?start=#{ start_time } &end=#{ end_time } " , headers : headers )
14
- config = Timeframe ::Application . config . local [ "calendars" ] . find { _1 [ "entity_id" ] == calendar [ "entity_id" ] }
15
16
16
17
res . map! do |event |
17
18
event [ "calendar_entity_id" ] = calendar [ "entity_id" ]
@@ -21,10 +22,8 @@ def prepare_response(response)
21
22
22
23
event [ "ends_at" ] = event [ "end" ] [ "date" ] || event [ "end" ] [ "dateTime" ]
23
24
24
- if config
25
- event [ "icon" ] = config [ "icon" ]
26
- event [ "letter" ] = config [ "letter" ]
27
- end
25
+ event [ "icon" ] = calendar [ "icon" ]
26
+ event [ "letter" ] = calendar [ "letter" ]
28
27
29
28
event [ "id" ] = event [ "uid" ]
30
29
@@ -42,7 +41,11 @@ def prepare_response(response)
42
41
out . concat ( res )
43
42
end
44
43
45
- out
44
+ save_response ( out )
45
+ end
46
+
47
+ def prepare_response ( response )
48
+ response
46
49
end
47
50
48
51
def headers
Original file line number Diff line number Diff line change 12
12
Sidekiq ::Cron ::Job . create (
13
13
name : "Fetch Home Assistant Calendar" ,
14
14
cron : "every 1 minute" ,
15
- args : [ "home_calendar " ] ,
15
+ args : [ "home_assistant_calendar " ] ,
16
16
class : "ScheduleJob"
17
17
)
18
18
23
23
class : "ScheduleJob"
24
24
)
25
25
26
- Sidekiq ::Cron ::Job . create (
27
- name : "Fetch Google Calendar" ,
28
- cron : "*/1 * * * *" ,
29
- args : [ "google_calendar" ] ,
30
- class : "ScheduleJob"
31
- )
26
+ # Sidekiq::Cron::Job.create(
27
+ # name: "Fetch Google Calendar",
28
+ # cron: "*/1 * * * *",
29
+ # args: ["google_calendar"],
30
+ # class: "ScheduleJob"
31
+ # )
32
32
33
33
Sidekiq ::Cron ::Job . create (
34
34
name : "Fetch Birdnet" ,
You can’t perform that action at this time.
0 commit comments