在我的旧报告中,我通过Delayed :: Job安排报告,其方法名称为“execute_schedule_reports”。
现在在我的新报告中,我有不同的方法名称“new_execute_schedule_reports”。
我想把所有旧的时间表报告移到新的。
旧报告对象是:
ScheduleReport.last
ScheduleReport Load (0.5ms) SELECT `schedule_reports`.* FROM `schedule_reports` ORDER BY `schedule_reports`.`id` DESC LIMIT 1
=> #<ScheduleReport id: 208, vendor_id: 116211, scheduled_report_store_type: "Club", scheduled_report_store_id: 116524, team_id: nil, product_id: "46067", abbreviate_product_name: nil, payment_status: nil, report_organizations: nil, date_filter: nil, report_name: 3, report_type: 0, email_to: "bcv@sdf.com", day: 2, repeat: nil, time: "12:15 AM", last_run_at: "2015-09-18 06:55:07", next_run_at: "2015-09-19 16:15:00", next_run_job_id: 1546516, created_at: "2015-09-18 06:51:33", updated_at: "2015-09-18 06:55:15", skip_items_with_zero_sale: false, club_id: nil, spirit_id: nil, from_date: "", to_date: "", standard_or_custom_report_id: nil, standard_or_custom_report: nil>
d = Delayed::Job.last
Delayed::Backend::ActiveRecord::Job Load (0.5ms) SELECT `delayed_jobs`.* FROM `delayed_jobs` ORDER BY `delayed_jobs`.`id` DESC LIMIT 1
=> #<Delayed::Backend::ActiveRecord::Job id: 1546516, priority: 20, attempts: 0, handler: "--- !ruby/object:Delayed::PerformableMethod\nobject...", last_error: nil, run_at: "2015-09-19 16:00:00", locked_at: nil, failed_at: nil, locked_by: nil, created_at: "2015-09-18 06:55:15", updated_at: "2015-09-18 06:55:15", queue: "schedule_report">
d.handler
=> "--- !ruby/object:Delayed::PerformableMethod\nobject: !ruby/class 'ScheduleReport'\nmethod_name: :execute_schedule_reports\nargs:\n- 208\n"
现在我需要修改Delayed :: Job Handler中的方法名称,使用新的“new_execute_schedule_reports”
如何修改此处理程序的方法名称?
这是我在使用gsub的想法!
这是一种正确的方法吗?
请建议我。
谢谢。
答案 0 :(得分:0)
grep -rl'execute_schedule_reports'./ | xargs sed -i's / execute_schedule_reports / new_execute_schedule_reports / g'
这将在相对于当前目录的所有文件中搜索字符串'execute_schedule_reports',并在每个文件中每次出现字符串时将'execute_schedule_reports'替换为'new_execute_schedule_reports'。