Class: Release

Inherits:
ApplicationRecord show all
Includes:
CacheMarkdownField, Gitlab::Utils::StrongMemoize, Importable, Presentable
Defined in:
app/models/release.rb

Constant Summary collapse

MAX_NUMBER_TO_DISPLAY =
3

Constants included from CacheMarkdownField

CacheMarkdownField::INVALIDATED_BY

Instance Attribute Summary

Attributes included from Importable

#imported, #importing

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from CacheMarkdownField

#attribute_invalidated?, #banzai_render_context, #cached_html_for, #cached_html_up_to_date?, #can_cache_field?, #invalidated_markdown_cache?, #latest_cached_markdown_version, #local_version, #parent_user, #refresh_markdown_cache, #refresh_markdown_cache!, #rendered_field_content, #skip_project_check?, #updated_cached_html_for

Methods included from Presentable

#present

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

Instance Method Details

#assets_count(except: []) ⇒ Object


51
52
53
54
55
56
# File 'app/models/release.rb', line 51

def assets_count(except: [])
  links_count = links.count
  sources_count = except.include?(:sources) ? 0 : sources.count

  links_count + sources_count
end

#commitObject


41
42
43
44
45
# File 'app/models/release.rb', line 41

def commit
  strong_memoize(:commit) do
    repository.commit(actual_sha)
  end
end

#historical_release?Boolean

Returns:

  • (Boolean)

68
69
70
# File 'app/models/release.rb', line 68

def historical_release?
  released_at.present? && released_at.to_i < created_at.to_i
end

#milestone_titlesObject


76
77
78
# File 'app/models/release.rb', line 76

def milestone_titles
  self.milestones.map {|m| m.title }.sort.join(", ")
end

#nameObject


72
73
74
# File 'app/models/release.rb', line 72

def name
  self.read_attribute(:name) || tag
end

#sourcesObject


58
59
60
61
62
# File 'app/models/release.rb', line 58

def sources
  strong_memoize(:sources) do
    Releases::Source.all(project, tag)
  end
end

#tag_missing?Boolean

Returns:

  • (Boolean)

47
48
49
# File 'app/models/release.rb', line 47

def tag_missing?
  actual_tag.nil?
end

#to_paramObject


37
38
39
# File 'app/models/release.rb', line 37

def to_param
  CGI.escape(tag)
end

#upcoming_release?Boolean

Returns:

  • (Boolean)

64
65
66
# File 'app/models/release.rb', line 64

def upcoming_release?
  released_at.present? && released_at.to_i > Time.zone.now.to_i
end