Skip to content

Commit c7f413c

Browse files
author
Tom Copeland
committed
Migrating forum_monitored_forums to watchers. Removed some unneeded block showing_migrated_ids parameters and fixed some arguments.
1 parent d1b9cc8 commit c7f413c

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

README.rdoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ Some notes on the differences between the GForge and the Redmine object models:
7070
artifact_status enumerations
7171
doc_data documents
7272
doc_groups document_categories
73-
filemodule_monitor
73+
filemodule_monitor
7474
forum messages
75-
forum_agg_msg_count
7675
forum_group_list boards
77-
forum_monitored_forums
76+
forum_monitored_forums watchers
7877
forum_perm
7978
forum_saved_place
8079
frs_dlstats_file
@@ -141,6 +140,7 @@ Some notes on the differences between the GForge and the Redmine object models:
141140
db_images - This table has only 1 record in the RubyForge DB
142141
doc_states - We're not migrating 'deleted' documents, and all others are just put in the public
143142
disk_usages
143+
forum_agg_msg_count
144144
gem_namespace_ownerships
145145
massmail_queue
146146
mirrors

lib/tasks/gforge_models.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class GForgeForumGroup < GForgeTable
3131
set_primary_key "group_forum_id"
3232
belongs_to :group, :class_name => "GForgeGroup"
3333
has_many :forum_messages, :class_name => "GForgeForumMessage", :foreign_key => "group_forum_id"
34+
has_many :monitors, :class_name => "GForgeForumMonitoredForum", :foreign_key => "forum_id"
3435
named_scope :active, :conditions => "is_public != 9"
3536
def convert_to_redmine_board_in(project)
3637
# I don't see an equivalent to allow_anonymous, is_public, or send_all_posts_to
@@ -55,6 +56,16 @@ def convert_to_redmine_message_in(board)
5556
message
5657
end
5758
end
59+
60+
class GForgeForumMonitoredForum < GForgeTable
61+
set_table_name 'forum_monitored_forums'
62+
set_primary_key 'monitor_id'
63+
belongs_to :user, :class_name => "GForgeUser", :foreign_key => 'user_id'
64+
belongs_to :forum_group, :class_name => "GForgeForumGroup", :foreign_key => "forum_id"
65+
def convert_to_redmine_watcher_on(board)
66+
board.watchers.create!(:user => create_or_fetch_user(user))
67+
end
68+
end
5869

5970
class GForgeUserGroup < GForgeTable
6071
set_table_name "user_group"

lib/tasks/migrate_from_gforge.rake

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ namespace :redmine do
7373
Member.create!(:principal => user, :project => project, :role_ids => [Role.find_by_name(role_name).id])
7474
end
7575
gforge_group.document_groups.each do |document_group|
76-
document_category = showing_migrated_ids(project) do
76+
document_category = showing_migrated_ids(document_group) do
7777
document_group.convert_to_redmine_document_category_on(project)
7878
end
7979
document_group.documents.each do |gforge_document|
80-
gforge_document = showing_migrated_ids(document_category) do
80+
gforge_document = showing_migrated_ids(gforge_document) do
8181
gforge_document.convert_to_redmine_document_in(document_category)
8282
end
8383
end
@@ -89,22 +89,22 @@ namespace :redmine do
8989
artifact.convert_to_redmine_issue_in(project)
9090
end
9191
artifact.monitors.each do |artifact_monitor|
92-
showing_migrated_ids(artifact_monitor) do |artifact_monitor|
92+
showing_migrated_ids(artifact_monitor) do
9393
artifact_monitor.convert_to_redmine_watcher_on(issue)
9494
end
9595
end
9696
artifact.messages.each do |artifact_message|
97-
showing_migrated_ids(artifact_message) do |artifact_message|
97+
showing_migrated_ids(artifact_message) do
9898
artifact_message.convert_to_redmine_journal_on(issue)
9999
end
100100
end
101101
artifact.files.each do |artifact_file|
102-
showing_migrated_ids(artifact_file) do |artifact_file|
102+
showing_migrated_ids(artifact_file) do
103103
artifact_file.convert_to_redmine_attachment_to(issue)
104104
end
105105
end
106106
artifact.histories.find(:all, :order => "entrydate asc").each do |artifact_history|
107-
showing_migrated_ids(artifact_history) do |artifact_history|
107+
showing_migrated_ids(artifact_history) do
108108
artifact_history.convert_to_redmine_journal_on(issue)
109109
end
110110
end
@@ -131,6 +131,11 @@ namespace :redmine do
131131
message.save!
132132
end
133133
end
134+
forum_group.monitors.each do |monitor|
135+
showing_migrated_ids(monitor) do
136+
monitor.convert_to_redmine_watcher_on(board)
137+
end
138+
end
134139
end
135140
#end
136141
end

0 commit comments

Comments
 (0)