Class: Packages::PackageFile
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Packages::PackageFile
- Includes:
- EachBatch, FileStoreMounter, Destructible, Installable, UpdateProjectStatistics
- Defined in:
- app/models/packages/package_file.rb
Constant Summary collapse
- INSTALLABLE_STATUSES =
[:default].freeze
Constants included from FileStoreMounter
FileStoreMounter::ALLOWED_FILE_FIELDS
Constants inherited from ApplicationRecord
Constants included from ResetOnUnionError
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary collapse
- .most_recent! ⇒ Object
-
.most_recent_for(packages, extra_join: nil, extra_where: nil) ⇒ Object
Returns the most recent installable package file for each of the given packages.
Instance Method Summary collapse
Methods included from AfterCommitQueue
#run_after_commit, #run_after_commit_or_now
Methods inherited from ApplicationRecord
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
Methods included from SensitiveSerializableHash
Class Method Details
.most_recent! ⇒ Object
100 101 102 |
# File 'app/models/packages/package_file.rb', line 100 def self.most_recent! recent.first! end |
.most_recent_for(packages, extra_join: nil, extra_where: nil) ⇒ Object
Returns the most recent installable package file for each of the given packages. The order is not guaranteed.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'app/models/packages/package_file.rb', line 118 def self.most_recent_for(packages, extra_join: nil, extra_where: nil) cte_name = :packages_cte cte = Gitlab::SQL::CTE.new(cte_name, packages.select(:id)) package_files = ::Packages::PackageFile.installable .limit_recent(1) .where(arel_table[:package_id].eq(Arel.sql("#{cte_name}.id"))) package_files = package_files.joins(extra_join) if extra_join package_files = package_files.where(extra_where) if extra_where query = select('finder.*') .from([Arel.sql(cte_name.to_s), package_files.arel.lateral.as('finder')]) query.with(cte.to_arel) end |
Instance Method Details
#download_path ⇒ Object
135 136 137 |
# File 'app/models/packages/package_file.rb', line 135 def download_path Gitlab::Routing.url_helpers.download_project_package_file_path(project, self) end |