Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sq::ScheduledContent.all.each do |sc|
- present_count = 0
- un_present_count = 0
- sc.groups.each do |g|
- g.learners.each do |u|
- if sc.content_type.present?
- d = "User#{sc.content_type.sub('Sq::', '')}"
- user_con = "#{sc.content_type}::#{d}".constantize.where(scheduled_content_id: sc.id, user_profile_id: u.id).first
- if user_con.nil?
- con = sc.content_type.sub('Sq::', '').underscore.downcase
- if (sc.featured_on > Time.now) || (sc.featured_on < Time.now && sc.expires_on > Time.now)
- "#{sc.content_type}::#{d}".constantize.collection.insert_one(scheduled_content_id: sc.id, user_profile_id: u.id, status: 'featured', "#{con}_id": sc.content_id)
- elsif (sc.featured_on < Time.now && sc.expires_on < Time.now)
- "#{sc.content_type}::#{d}".constantize.collection.insert_one(scheduled_content_id: sc.id, user_profile_id: u.id, status: 'pending', "#{con}_id": sc.content_id)
- end
- elsif user_con.present?
- "#{sc.content_type}::#{d}".constantize.skip_callback(:save, :before, :update_timestamp)
- if (sc.content.expires_on < Time.now)
- user_con.update_attributes(status: "pending_archieved")
- elsif (user_con.started_archieved == "started")
- user_con.update_attributes(status: "started_archieved")
- end
- "#{sc.content_type}::#{d}".constantize.set_callback(:save, :before, :update_timestamp)
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment