Follow-up: Refactor to hide first cars for each train implementation
The following discussion from !124661 (merged) should be addressed:
-
@drew started a discussion: (+3 comments)
I actually think we can eventually remove the concept of first train car entirely and just have a method to get each train.
The first train car method is kind of a confusing abstraction because it makes it seem like it's important that we get the first car but we are just iterating through each train without a train table. We can hide the details behind an abstraction:
# ee/app/models/merge_trains/train.rb class Train def self.all_for(project) MergeTrains::Car .active .where(target_project: project) .select('DISTINCT ON (target_branch) *') .map(&:train) end def refresh MergeTrains::RefreshWorker.perform_async(@project_id, @target_branch) end
# ee/app/services/ee/projects/update_service.rb MergeTrains::Train.all_for(project).each { |train| train.refresh }
cc. @hfyngvason
Edited by Allison Browne