Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit f0806ea

Browse files
committed
fetching events from scheduler
1 parent fb03552 commit f0806ea

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed

apps/web/controllers/events/index.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ class Index
77
operation: 'operations.event.index'
88
]
99

10+
expose :events
11+
1012
def call(_)
1113
@events = operation.call
12-
p @events
1314
end
1415

1516
end
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
.container
2-
= @events
1+
%table.table.table-bordered.table-hover.table-sm
2+
%thead
3+
%tr
4+
%th Name
5+
%th Task
6+
%th Frequency
7+
%th
8+
%tbody
9+
- events.each do |event|
10+
%tr
11+
%td= event.name
12+
%td= event.task_id
13+
%td= event.frequency
14+
%td
15+
= edit_button("#")
16+
= remove_button("#")
17+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Event
2+
attr_reader :id, :name, :task_id, :frequency_period, :frequency_quantity
3+
4+
def initialize(id:, name:, task_id:, frequency_period:, frequency_quantity:)
5+
@id = id
6+
@name = name
7+
@task_id = task_id
8+
@frequency_period = frequency_period
9+
@frequency_quantity = frequency_quantity
10+
end
11+
12+
def frequency
13+
"#{frequency_quantity} #{frequency_period}"
14+
end
15+
end

lib/omniscrapper_hq/operations/event/index.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
module Operations
22
module Event
33
class Index < Base
4-
GRAPHQL_CLIENT = System::Container['omniscrapper.graphql_client']
4+
GRAPHQL_CLIENT ||= System::Container['omniscrapper.graphql_client']
55

6-
Query = GRAPHQL_CLIENT.parse <<-'GRAPHQL'
6+
Query ||= GRAPHQL_CLIENT.parse <<-'GRAPHQL'
77
query {
88
events {
99
id,
1010
name,
11+
taskId,
1112
frequencyPeriod,
1213
frequencyQuantity
1314
}
@@ -16,7 +17,16 @@ class Index < Base
1617

1718

1819
def call
19-
GRAPHQL_CLIENT.query(Query)
20+
results = GRAPHQL_CLIENT.query(Query)
21+
results.data.events.map do |event|
22+
::Event.new(
23+
id: event.id,
24+
name: event.name,
25+
task_id: event.task_id,
26+
frequency_quantity: event.frequency_quantity,
27+
frequency_period: event.frequency_period
28+
)
29+
end
2030
end
2131
end
2232
end

0 commit comments

Comments
 (0)