Skip to content

Instantly share code, notes, and snippets.

@danielmfern
Last active January 23, 2026 13:31
Show Gist options
  • Select an option

  • Save danielmfern/1b08beecb301618be911e2b1469fddec to your computer and use it in GitHub Desktop.

Select an option

Save danielmfern/1b08beecb301618be911e2b1469fddec to your computer and use it in GitHub Desktop.
# Editables + Variants
mocacos_done = Flow::ShotImage
.joins(shot: { task: :card })
.where(step: 'final', flag: 'f1', extension: 'jpg')
.merge(Flow::Card.where(campaign: 'V2026'))
.distinct
.pluck(:partnumber_value)
mocacos_done.count
# 4740
# Shots finales e1.jpg de V2026
all_mocacos = Flow::ShotImage
.joins(shot: { task: :card })
.where(step: 'final', flag: 'e1', extension: 'jpg')
.merge(Flow::Card.where(campaign: 'V2026'))
.distinct
.pluck(:partnumber_value)
all_mocacos.count
# 4876
# skipping those starting with 2 (BEAUTY)
pending_mocacos = (all_mocacos - mocacos_done).compact.uniq.reject { |pn| pn.start_with?('2') }
pending_mocacos.count
# 53
pending_mocacos.each do |pn|
shot_id = Flow::ShotImage
.joins(shot: { task: :card })
.where(step: 'final', flag: 'e1', extension: 'png')
.merge(Flow::Card.where(campaign: 'V2026', partnumber_value: pn))
.order(created_at: :desc)
.pluck(:flow_shot_id)
.uniq
shot = Flow::Shot.find_by(id: shot_id.first)
next unless shot.present?
filename = shot.download_filename('retouch').gsub(shot.id.to_s, shot.parent_variant.id.to_s)
actions = Flow::AutomaticActions::DetectionService.new(filename).execute
action_code = 'background_remove_jpg'
output_filename = actions.find { |a| a['action'] == action_code }['output_filename']
action_execution = Flow::ActionExecution.create!(
filename:,
output_filename:,
blob_id: shot.file.signed_id,
action_code:,
user_action_id: '-999999', # Generar un nuevo user_action_id por "batch"
request_params: { step: 'final' }
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment