Class: ProjectFeatureUsage

Inherits:
ApplicationRecord show all
Defined in:
app/models/project_feature_usage.rb

Constant Summary collapse

JIRA_DVCS_CLOUD_FIELD =
'jira_dvcs_cloud_last_sync_at'.freeze
JIRA_DVCS_SERVER_FIELD =
'jira_dvcs_server_last_sync_at'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.jira_dvcs_integration_field(cloud: true) ⇒ Object


17
18
19
# File 'app/models/project_feature_usage.rb', line 17

def jira_dvcs_integration_field(cloud: true)
  cloud ? JIRA_DVCS_CLOUD_FIELD : JIRA_DVCS_SERVER_FIELD
end

Instance Method Details

#log_jira_dvcs_integration_usage(cloud: true) ⇒ Object


22
23
24
25
26
27
28
29
30
# File 'app/models/project_feature_usage.rb', line 22

def log_jira_dvcs_integration_usage(cloud: true)
  transaction(requires_new: true) do
    save unless persisted?
    touch(self.class.jira_dvcs_integration_field(cloud: cloud))
  end
rescue ActiveRecord::RecordNotUnique
  reset
  retry
end