|
- require 'trustie/gitlab/sync'
-
- namespace :trustie do
- namespace :files do
- desc "sync course'file"
- task :course => :environment do
- # Course.all.each do |course|
- # unless course.attachments.count.to_i == 0
- # attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and container_type ='Course'").count
- # project_score = ProjectScore.where("project_id=?", project.id).first
- # if project_score.nil?
- # ProjectScore.create(:project_id => project.id, :attach_num => 0)
- # else
- # project_score.attach_num = attachment_count
- # project_score.save
- # end
- # end
- # end
- end
-
- desc "sync project'file"
- task :project => :environment do
- Project.all.each do |project|
- unless project.attachments.count.to_i == 0
- attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{project.id} and container_type ='Project'").count
- project_score = ProjectScore.where("project_id=?", project.id).first
- if project_score.nil?
- ProjectScore.create(:project_id => project.id, :attach_num => 0)
- else
- project_score.attach_num = attachment_count
- project_score.save
- end
- end
- end
- end
-
- end
- end
|