Class: WebHookLog
Constant Summary
collapse
- OVERSIZE_REQUEST_DATA =
{ 'oversize' => true }.freeze
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#present
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#serializable_hash
Instance Attribute Details
#interpolated_url ⇒ Object
Returns the value of attribute interpolated_url.
11
12
13
|
# File 'app/models/hooks/web_hook_log.rb', line 11
def interpolated_url
@interpolated_url
end
|
Class Method Details
.delete_batch_for(web_hook, batch_size:) ⇒ Object
Delete a batch of log records. Returns true if there may be more remaining.
35
36
37
38
39
|
# File 'app/models/hooks/web_hook_log.rb', line 35
def self.delete_batch_for(web_hook, batch_size:)
raise ArgumentError, 'batch_size is too small' if batch_size < 1
where(web_hook: web_hook).limit(batch_size).delete_all == batch_size
end
|
.recent ⇒ Object
29
30
31
32
|
# File 'app/models/hooks/web_hook_log.rb', line 29
def self.recent
where(created_at: 2.days.ago.beginning_of_day..Time.zone.now)
.order(created_at: :desc)
end
|
Instance Method Details
#internal_error? ⇒ Boolean
#oversize? ⇒ Boolean
49
50
51
|
# File 'app/models/hooks/web_hook_log.rb', line 49
def oversize?
request_data == OVERSIZE_REQUEST_DATA
end
|
53
54
55
56
57
58
|
# File 'app/models/hooks/web_hook_log.rb', line 53
def
super unless web_hook.token?
super if self[:request_headers]['X-Gitlab-Token'] == _('[REDACTED]')
self[:request_headers].merge('X-Gitlab-Token' => _('[REDACTED]'))
end
|
#success? ⇒ Boolean
41
42
43
|
# File 'app/models/hooks/web_hook_log.rb', line 41
def success?
response_status =~ /^2/
end
|
#url_current? ⇒ Boolean
60
61
62
63
64
65
66
|
# File 'app/models/hooks/web_hook_log.rb', line 60
def url_current?
return true if url_hash.nil?
Gitlab::CryptoHelper.sha256(web_hook.interpolated_url) == url_hash
end
|