标签:
need_fetch_channel.each do |channel| yesterday = (Time.now - 86000).to_i all_channel_videos = channel.videos.asc(:begin_time) all_channel_videos.each do |v| if v.end_time < yesterday v.destroy end end
end
重构完
need_fetch_channel.videos.where(:end_time.lt => DateTime.yesterday.midnight).destroy_all
DateTime.yesterday.midnight
获取的是昨天的凌晨零点的时间
标签:
原文地址:http://www.cnblogs.com/iwangzheng/p/4685672.html