Module: WebhookTrigger::Repository::TriggerRepository
- Defined in:
- lib/webhook_trigger/repository/trigger_repository.rb
Overview
This TriggerRepository is class for connect to database
Class Method Summary collapse
- .webhook_insert_pending(event, url, event_source_id) ⇒ Object
- .webhook_insert_query ⇒ Object
- .webhook_insert_value(event, url, event_source_id) ⇒ Object
- .webhook_list(event, account_id) ⇒ Object
- .webhook_list_query_condition(event, account_id) ⇒ Object
- .webhook_list_query_join ⇒ Object
- .webhook_list_query_select ⇒ Object
Class Method Details
.webhook_insert_pending(event, url, event_source_id) ⇒ Object
52 53 54 55 56 |
# File 'lib/webhook_trigger/repository/trigger_repository.rb', line 52 def self.webhook_insert_pending(event, url, event_source_id) sql = webhook_insert_query sql += webhook_insert_value(event, url, event_source_id) WebhookTrigger::Repository.client.query(sql) end |
.webhook_insert_query ⇒ Object
39 40 41 42 43 44 |
# File 'lib/webhook_trigger/repository/trigger_repository.rb', line 39 def self.webhook_insert_query sql = 'INSERT INTO ' + configuration.db + '.' sql += configuration.buffer_table sql += '(url, event, event_source_id) VALUES ' sql end |
.webhook_insert_value(event, url, event_source_id) ⇒ Object
46 47 48 49 50 |
# File 'lib/webhook_trigger/repository/trigger_repository.rb', line 46 def self.webhook_insert_value(event, url, event_source_id) sql = "('" + url.to_s + "', '" + event.to_s + "', " sql += event_source_id.to_s + ')' sql end |
.webhook_list(event, account_id) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/webhook_trigger/repository/trigger_repository.rb', line 32 def self.webhook_list(event, account_id) sql = webhook_list_query_select sql += webhook_list_query_condition(event, account_id) results = WebhookTrigger::Repository.client.query(sql) results end |
.webhook_list_query_condition(event, account_id) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/webhook_trigger/repository/trigger_repository.rb', line 24 def self.webhook_list_query_condition(event, account_id) sql = 'WHERE ' + configuration_list sql += '.account_id=' + account_id.to_s sql += ' AND ' + configuration_event sql += ".name like '" + event.to_s + "'" sql end |
.webhook_list_query_join ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/webhook_trigger/repository/trigger_repository.rb', line 16 def self.webhook_list_query_join sql = ' FROM ' + configuration_list sql += ' JOIN ' + configuration_event sql += ' on ' + configuration_list + '.event_id=' sql += configuration_event + '.id ' sql end |
.webhook_list_query_select ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/webhook_trigger/repository/trigger_repository.rb', line 8 def self.webhook_list_query_select sql = 'SELECT ' + configuration_list + '.id, ' sql += configuration_list + '.url, ' sql += configuration_event + '.name ' sql += webhook_list_query_join sql end |