This repository was archived by the owner on Feb 20, 2022. It is now read-only.
File tree 6 files changed +48
-4
lines changed
lib/loader/asset/loaders/aws_loader
6 files changed +48
-4
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
1
3
#
2
4
# Load Support assets into RedisGraph
3
5
#
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ def perform
81
81
puts "Processing results finished - #{ guid } "
82
82
83
83
job . complete!
84
+ job . send_webhook
84
85
puts "Runner job finished - #{ guid } "
85
86
rescue StandardError => e
86
87
job . failed!
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Campaign
5
+ #
1
6
class Campaign < ApplicationRecord
2
7
belongs_to :user
3
8
before_save :update_control_count
4
9
10
+ validates :name , presence : true , length : { maximum : 120 }
11
+
5
12
#
6
13
# Return the Controls that match this Campaign's filters
7
14
#
@@ -24,9 +31,7 @@ def controls
24
31
# filters MAY have a Tags filter
25
32
controls = controls . where ( tags : { name : tags_filter } ) if tags_filter && !tags_filter . empty?
26
33
# filters MAY have "all" tags flag set
27
- if must_have_all_tags
28
- controls = controls . having ( 'json_agg(tags.name)::jsonb @> ?::jsonb' , tags_filter . to_s )
29
- end
34
+ controls = controls . having ( 'json_agg(tags.name)::jsonb @> ?::jsonb' , tags_filter . to_s ) if must_have_all_tags
30
35
31
36
controls
32
37
end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Generic Job
5
+ #
1
6
class Job < ApplicationRecord
2
7
has_many :results
3
8
@@ -13,4 +18,29 @@ class Job < ApplicationRecord
13
18
parse : 3 ,
14
19
cleanup : 4
15
20
} , _prefix : :job
21
+
22
+ #
23
+ # Send an external webhook
24
+ #
25
+ def send_webhook
26
+ config = Rails . application . config_for ( :webhooks )
27
+
28
+ return unless config . webhooks
29
+
30
+ config . webhooks . each do |_k , webhook |
31
+ next if webhook . nil?
32
+
33
+ url = URI ( webhook )
34
+ headers = { 'content-type' => 'application/json' }
35
+ payload = {
36
+ 'job_id' => id ,
37
+ 'job_type' => kind ,
38
+ 'status' => status ,
39
+ 'results' => results . count
40
+ } . to_json
41
+ res = Net ::HTTP . post ( URI ( url ) , payload , headers )
42
+
43
+ res . code
44
+ end
45
+ end
16
46
end
Original file line number Diff line number Diff line change
1
+ development :
2
+ webhooks :
3
+ runner_job : <%= ENV['JOB_WEBHOOK_URL'] %>
4
+ production :
5
+ webhooks :
6
+ runner_job : <%= ENV['JOB_WEBHOOK_URL'] %>
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ x-app: &app
6
6
RAILS_ENV : ${RAILS_ENV:-production}
7
7
RAILS_SERVE_STATIC_FILES : 1
8
8
RAILS_LOG_TO_STDOUT : 1
9
- image : gcr.io/opencspm/engine:0.1.17
9
+ image : gcr.io/opencspm/engine:0.1.18
10
10
tmpfs :
11
11
- /tmp
12
12
You can’t perform that action at this time.
0 commit comments