Class: Packages::BuildInfosFinder
- Inherits:
-
Object
- Object
- Packages::BuildInfosFinder
- Includes:
- ActiveRecord::ConnectionAdapters::Quoting
- Defined in:
- app/finders/packages/build_infos_finder.rb
Constant Summary collapse
- MAX_PAGE_SIZE =
100
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(package_ids, params) ⇒ BuildInfosFinder
constructor
A new instance of BuildInfosFinder.
Constructor Details
#initialize(package_ids, params) ⇒ BuildInfosFinder
Returns a new instance of BuildInfosFinder.
9 10 11 12 |
# File 'app/finders/packages/build_infos_finder.rb', line 9 def initialize(package_ids, params) @package_ids = package_ids @params = params end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/finders/packages/build_infos_finder.rb', line 14 def execute return Packages::BuildInfo.none if @package_ids.blank? # This is a highly custom query that # will not be re-used elsewhere # rubocop: disable CodeReuse/ActiveRecord query = Packages::Package.id_in(@package_ids) .select('build_infos.*') .from([Packages::Package.arel_table, lateral_query.arel.lateral.as('build_infos')]) .order('build_infos.id DESC') # We manually select build_infos fields from the lateral query. # Thus, we need to instruct ActiveRecord that returned rows are # actually Packages::BuildInfo objects Packages::BuildInfo.find_by_sql(query.to_sql) # rubocop: enable CodeReuse/ActiveRecord end |