| |   |
| 7 | 7 | |
| 8 | 8 | abort("Usage: #{$0} repo_id") unless ARGV[0] |
| 9 | 9 | |
| 10 | $stdout.sync = true |
| 11 | |
| 10 | 12 | def create_repo_creation_events_for(project) |
| 11 | 13 | project.repository_clones.each do |repo| |
| 12 | 14 | puts "creating Repository clone event in #{project.slug}/#{repo.name}" |
| 13 | | # project.create_event(Action::CLONE_REPOSITORY, repo, repo.user, repo.parent_id) |
| 14 | 15 | project.events.create({ |
| 15 | 16 | :action => Action::CLONE_REPOSITORY, |
| 16 | 17 | :target => repo, |
| … | … | |
| 25 | 25 | def create_comment_events_for(repo, project) |
| 26 | 26 | repo.comments.each do |comment| |
| 27 | 27 | puts "creating Comment event on #{project.slug}/#{repo.name}" |
| 28 | | #project.create_event(Action::COMMENT, comment, comment.user) |
| 29 | 28 | project.events.create({ |
| 30 | 29 | :action => Action::COMMENT, |
| 31 | 30 | :target => comment, |
| … | … | |
| 67 | 67 | users_commits[commit.committer.email] ||= [] |
| 68 | 68 | users_commits[commit.committer.email] << commit |
| 69 | 69 | end |
| 70 | | |
| 70 | |
| 71 | 71 | users = User.find(:all, :conditions => ['email in (?)', users_commits.keys] ) |
| 72 | 72 | users.each do |user| |
| 73 | 73 | commits = users_commits[user.email] |
| 74 | | |
| 74 | puts "\nindexing #{commits.size} commits for #{user.email} in #{project.slug}/#{repo.name}:#{head.name}" |
| 75 | 75 | commits.each_index do |i| |
| 76 | 76 | commit = commits[i] |
| 77 | 77 | previous_commit = commits[i-1] |
| … | … | |
| 152 | 152 | end |
| 153 | 153 | end |
| 154 | 154 | |
| 155 | | puts "#{current_rev_type}#{action.inspect} in #{project.slug}/#{repo.name}:#{head.name}: #{commit.short_message}" |
| 156 | | #project.create_event(action_id, repo, user, commit.id, commit.message) |
| 155 | print "." if (i % 10 == 1) |
| 156 | #puts "#{current_rev_type}#{action.inspect} in #{project.slug}/#{repo.name}:#{head.name}: #{commit.short_message}" |
| 157 | 157 | project.events.create({ |
| 158 | 158 | :action => action_id || Action::COMMIT, |
| 159 | 159 | :target => repo, |
| … | … | |
| 163 | 163 | :created_at => commit.committed_date}) |
| 164 | 164 | end |
| 165 | 165 | commits = nil |
| 166 | puts |
| 166 | 167 | end |
| 167 | 168 | users_commits = nil |
| 168 | 169 | end |
| toggle raw diff |
--- a/script/rebuild_events
+++ b/script/rebuild_events
@@ -7,10 +7,11 @@ require File.dirname(__FILE__) + "/../config/environment"
abort("Usage: #{$0} repo_id") unless ARGV[0]
+$stdout.sync = true
+
def create_repo_creation_events_for(project)
project.repository_clones.each do |repo|
puts "creating Repository clone event in #{project.slug}/#{repo.name}"
- # project.create_event(Action::CLONE_REPOSITORY, repo, repo.user, repo.parent_id)
project.events.create({
:action => Action::CLONE_REPOSITORY,
:target => repo,
@@ -24,7 +25,6 @@ end
def create_comment_events_for(repo, project)
repo.comments.each do |comment|
puts "creating Comment event on #{project.slug}/#{repo.name}"
- #project.create_event(Action::COMMENT, comment, comment.user)
project.events.create({
:action => Action::COMMENT,
:target => comment,
@@ -67,11 +67,11 @@ def create_events_for_repository(repo, project)
users_commits[commit.committer.email] ||= []
users_commits[commit.committer.email] << commit
end
-
+
users = User.find(:all, :conditions => ['email in (?)', users_commits.keys] )
users.each do |user|
commits = users_commits[user.email]
-
+ puts "\nindexing #{commits.size} commits for #{user.email} in #{project.slug}/#{repo.name}:#{head.name}"
commits.each_index do |i|
commit = commits[i]
previous_commit = commits[i-1]
@@ -152,8 +152,8 @@ def create_events_for_repository(repo, project)
end
end
- puts "#{current_rev_type}#{action.inspect} in #{project.slug}/#{repo.name}:#{head.name}: #{commit.short_message}"
- #project.create_event(action_id, repo, user, commit.id, commit.message)
+ print "." if (i % 10 == 1)
+ #puts "#{current_rev_type}#{action.inspect} in #{project.slug}/#{repo.name}:#{head.name}: #{commit.short_message}"
project.events.create({
:action => action_id || Action::COMMIT,
:target => repo,
@@ -163,6 +163,7 @@ def create_events_for_repository(repo, project)
:created_at => commit.committed_date})
end
commits = nil
+ puts
end
users_commits = nil
end |