]> git.openstreetmap.org Git - rails.git/commitdiff
Rename some columns and indexes in the bug tables
authorTom Hughes <tom@compton.nu>
Sun, 8 May 2011 16:39:27 +0000 (17:39 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 17 May 2011 23:36:00 +0000 (00:36 +0100)
13 files changed:
app/controllers/map_bugs_controller.rb
app/models/map_bug.rb
app/models/map_bug_comment.rb
app/models/notifier.rb
app/views/browse/bug.html.erb
app/views/map_bugs/_bug.rss.builder
app/views/map_bugs/_bug.xml.builder
app/views/map_bugs/my_bugs.html.erb
app/views/map_bugs/rss.rss.builder
db/migrate/20110508145337_cleanup_bug_tables.rb [new file with mode: 0644]
test/fixtures/map_bug_comment.yml
test/fixtures/map_bugs.yml
test/functional/map_bugs_controller_test.rb

index f4105929ffe06a3ef4e3f80a266e739da08eeeb5..8bd45bbcdefc3ec571eeb21ac87f972d5dd71ba8 100644 (file)
@@ -39,14 +39,14 @@ class MapBugsController < ApplicationController
        
     check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_BUG_REQUEST_AREA)
 
        
     check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_BUG_REQUEST_AREA)
 
-    @bugs = MapBug.find_by_area(@min_lat, @min_lon, @max_lat, @max_lon, :include => :comments, :order => "last_changed DESC", :limit => limit, :conditions => conditions)
+    @bugs = MapBug.find_by_area(@min_lat, @min_lon, @max_lat, @max_lon, :include => :comments, :order => "updated_at DESC", :limit => limit, :conditions => conditions)
 
     respond_to do |format|
       format.html {render :template => 'map_bugs/get_bugs.js', :content_type => "text/javascript"}
       format.rss {render :template => 'map_bugs/get_bugs.rss'}
       format.js
       format.xml {render :template => 'map_bugs/get_bugs.xml'}
 
     respond_to do |format|
       format.html {render :template => 'map_bugs/get_bugs.js', :content_type => "text/javascript"}
       format.rss {render :template => 'map_bugs/get_bugs.rss'}
       format.js
       format.xml {render :template => 'map_bugs/get_bugs.xml'}
-      format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :comments => { :only => [:commenter_name, :date_created, :comment]}}) }        
+      format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) }          
       format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
     end
   end
       format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
     end
   end
@@ -80,9 +80,10 @@ class MapBugsController < ApplicationController
       rescue Exception => err
         @bug.nearby_place = "unknown"
       end
       rescue Exception => err
         @bug.nearby_place = "unknown"
       end
-         
+
       @bug.save
       @bug.save
-      add_comment(@bug, comment, name,"opened")
+
+      add_comment(@bug, comment, name, "opened")
     end
  
     render_ok
     end
  
     render_ok
@@ -102,7 +103,7 @@ class MapBugsController < ApplicationController
     raise OSM::APIAlreadyDeletedError unless bug.visible
 
     MapBug.transaction do
     raise OSM::APIAlreadyDeletedError unless bug.visible
 
     MapBug.transaction do
-      bug_comment = add_comment(bug, params['text'], name,"commented")
+      bug_comment = add_comment(bug, params['text'], name, "commented")
     end
 
     render_ok
     end
 
     render_ok
@@ -121,7 +122,7 @@ class MapBugsController < ApplicationController
 
     MapBug.transaction do
       bug.close_bug
 
     MapBug.transaction do
       bug.close_bug
-      add_comment(bug,:nil,name,"closed")
+      add_comment(bug, :nil, name, "closed")
     end
 
     render_ok
     end
 
     render_ok
@@ -143,7 +144,7 @@ class MapBugsController < ApplicationController
       conditions = cond_merge conditions, [OSM.sql_for_area(@min_lat, @min_lon, @max_lat, @max_lon)]
     end
 
       conditions = cond_merge conditions, [OSM.sql_for_area(@min_lat, @min_lon, @max_lat, @max_lon)]
     end
 
-    @comments = MapBugComment.find(:all, :limit => limit, :order => "date_created DESC", :joins => :map_bug, :include => :map_bug, :conditions => conditions)
+    @comments = MapBugComment.find(:all, :limit => limit, :order => "created_at DESC", :joins => :map_bug, :include => :map_bug, :conditions => conditions)
     render :template => 'map_bugs/rss.rss'
   end
 
     render :template => 'map_bugs/rss.rss'
   end
 
@@ -155,7 +156,7 @@ class MapBugsController < ApplicationController
     respond_to do |format|
       format.rss
       format.xml
     respond_to do |format|
       format.rss
       format.xml
-      format.json { render :json => @bug.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :comments => { :only => [:commenter_name, :date_created, :comment]}}) }         
+      format.json { render :json => @bug.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) }   
       format.gpx
     end
   end
       format.gpx
     end
   end
@@ -178,11 +179,11 @@ class MapBugsController < ApplicationController
     raise OSM::APIBadUserInput.new("No query string was given") unless params['q']
     limit = getLimit
     conditions = closedCondition
     raise OSM::APIBadUserInput.new("No query string was given") unless params['q']
     limit = getLimit
     conditions = closedCondition
-    conditions = cond_merge conditions, ['map_bug_comment.comment ~ ?', params['q']]
+    conditions = cond_merge conditions, ['map_bug_comment.body ~ ?', params['q']]
        
     #TODO: There should be a better way to do this.   CloseConditions are ignored at the moment
 
        
     #TODO: There should be a better way to do this.   CloseConditions are ignored at the moment
 
-    bugs2 = MapBug.find(:all, :limit => limit, :order => "last_changed DESC", :joins => :comments, :include => :comments,
+    bugs2 = MapBug.find(:all, :limit => limit, :order => "updated_at DESC", :joins => :comments, :include => :comments,
                         :conditions => conditions)
     @bugs = bugs2.uniq
     respond_to do |format|
                         :conditions => conditions)
     @bugs = bugs2.uniq
     respond_to do |format|
@@ -190,7 +191,7 @@ class MapBugsController < ApplicationController
       format.rss {render :template => 'map_bugs/get_bugs.rss'}
       format.js
       format.xml {render :template => 'map_bugs/get_bugs.xml'}
       format.rss {render :template => 'map_bugs/get_bugs.rss'}
       format.js
       format.xml {render :template => 'map_bugs/get_bugs.xml'}
-      format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :comments => { :only => [:commenter_name, :date_created, :comment]}}) }
+      format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) }
       format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
     end
   end
       format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
     end
   end
@@ -201,7 +202,7 @@ class MapBugsController < ApplicationController
  
       if @user2  
         if @user2.data_public? or @user2 == @user 
  
       if @user2  
         if @user2.data_public? or @user2 == @user 
-          conditions = ['map_bug_comment.commenter_id = ?', @user2.id] 
+          conditions = ['map_bug_comment.author_id = ?', @user2.id] 
         else 
           conditions = ['false'] 
         end 
         else 
           conditions = ['false'] 
         end 
@@ -227,7 +228,7 @@ class MapBugsController < ApplicationController
     @bugs = MapBug.find(:all, 
                         :include => [:comments, {:comments => :user}],
                         :joins => :comments,
     @bugs = MapBug.find(:all, 
                         :include => [:comments, {:comments => :user}],
                         :joins => :comments,
-                        :order => "last_changed DESC",
+                        :order => "updated_at DESC",
                         :conditions => conditions,
                         :offset => (@page - 1) * @page_size, 
                         :limit => @page_size).uniq
                         :conditions => conditions,
                         :offset => (@page - 1) * @page_size, 
                         :limit => @page_size).uniq
@@ -278,7 +279,7 @@ private
     if closed_since < 0
       conditions = ["status != 'hidden'"]
     elsif closed_since > 0
     if closed_since < 0
       conditions = ["status != 'hidden'"]
     elsif closed_since > 0
-      conditions = ["((status = 'open') OR ((status = 'closed' ) AND (date_closed > '" + (Time.now - closed_since.days).to_s + "')))"]
+      conditions = ["((status = 'open') OR ((status = 'closed' ) AND (closed_at > '" + (Time.now - closed_since.days).to_s + "')))"]
     else
       conditions = ["status = 'open'"]
     end
     else
       conditions = ["status = 'open'"]
     end
@@ -287,18 +288,16 @@ private
   end
 
   def add_comment(bug, comment, name,event) 
   end
 
   def add_comment(bug, comment, name,event) 
-    t = Time.now.getutc 
-    bug_comment = bug.comments.create(:date_created => t, :visible => true, :event => event)
-    bug_comment.comment = comment unless comment == :nil
+    bug_comment = bug.comments.create(:visible => true, :event => event)
+    bug_comment.body = comment unless comment == :nil
     if @user  
     if @user  
-      bug_comment.commenter_id = @user.id
-      bug_comment.commenter_name = @user.display_name
+      bug_comment.author_id = @user.id
+      bug_comment.author_name = @user.display_name
     else  
     else  
-      bug_comment.commenter_ip = request.remote_ip
-      bug_comment.commenter_name = name + " (a)"
+      bug_comment.author_ip = request.remote_ip
+      bug_comment.author_name = name + " (a)"
     end
     bug_comment.save 
     end
     bug_comment.save 
-    bug.last_changed = t 
     bug.save
 
     sent_to = Set.new
     bug.save
 
     sent_to = Set.new
index b07ef2941d290cfce75363e1ce957ff118ccb69b..2ae110bf2fcc897c30f56f8dde60f60c5e9641be 100644 (file)
@@ -1,36 +1,28 @@
 class MapBug < ActiveRecord::Base
   include GeoRecord
 
 class MapBug < ActiveRecord::Base
   include GeoRecord
 
-  has_many :comments, :class_name => "MapBugComment", 
-                      :foreign_key => :bug_id, 
-                      :order => :date_created, 
-                      :conditions => "visible = true and comment is not null"
+  has_many :comments, :class_name => "MapBugComment",
+                      :foreign_key => :bug_id,
+                      :order => :created_at,
+                      :conditions => "visible = true AND body IS NOT NULL"
 
   validates_presence_of :id, :on => :update
   validates_uniqueness_of :id
   validates_numericality_of :latitude, :only_integer => true
   validates_numericality_of :longitude, :only_integer => true
 
   validates_presence_of :id, :on => :update
   validates_uniqueness_of :id
   validates_numericality_of :latitude, :only_integer => true
   validates_numericality_of :longitude, :only_integer => true
-  validates_presence_of :date_created
-  validates_presence_of :last_changed
-  validates_presence_of :date_closed if :status == "closed"
+  validates_presence_of :closed_at if :status == "closed"
   validates_inclusion_of :status, :in => ["open", "closed", "hidden"]
 
   def self.create_bug(lat, lon)
   validates_inclusion_of :status, :in => ["open", "closed", "hidden"]
 
   def self.create_bug(lat, lon)
-    bug = MapBug.new(:lat => lat, :lon => lon)
+    bug = MapBug.new(:lat => lat, :lon => lon, :status => "open")
     raise OSM::APIBadUserInput.new("The node is outside this world") unless bug.in_world?
 
     raise OSM::APIBadUserInput.new("The node is outside this world") unless bug.in_world?
 
-    bug.date_created = Time.now.getutc
-    bug.last_changed = Time.now.getutc
-    bug.status = "open"
-
     return bug
   end
 
   def close_bug
     self.status = "closed"
     return bug
   end
 
   def close_bug
     self.status = "closed"
-    close_time = Time.now.getutc
-    self.last_changed = close_time
-    self.date_closed = close_time
+    self.closed_at = Time.now.getutc
 
     self.save
   end
 
     self.save
   end
@@ -39,12 +31,12 @@ class MapBug < ActiveRecord::Base
     resp = ""
     comment_no = 1
     self.comments.each do |comment|
     resp = ""
     comment_no = 1
     self.comments.each do |comment|
-      next if upto_timestamp != :nil and comment.date_created > upto_timestamp
+      next if upto_timestamp != :nil and comment.created_at > upto_timestamp
       resp += (comment_no == 1 ? "" : separator_char)
       resp += (comment_no == 1 ? "" : separator_char)
-      resp += comment.comment if comment.comment
+      resp += comment.body if comment.body
       resp += " [ " 
       resp += " [ " 
-      resp += comment.commenter_name if comment.commenter_name
-      resp += " " + comment.date_created.to_s + " ]"
+      resp += comment.author_name if comment.author_name
+      resp += " " + comment.created_at.to_s + " ]"
       comment_no += 1
     end
 
       comment_no += 1
     end
 
index 50bfe3bef40c6af44ae3cc69f03e09f70a24a37b..28f16a9a99fead3338695658ca0167524fcc349d 100644 (file)
@@ -2,17 +2,16 @@ class MapBugComment < ActiveRecord::Base
   set_table_name 'map_bug_comment'
 
   belongs_to :map_bug, :foreign_key => 'bug_id'
   set_table_name 'map_bug_comment'
 
   belongs_to :map_bug, :foreign_key => 'bug_id'
-  belongs_to :user, :foreign_key => 'commenter_id'
+  belongs_to :user, :foreign_key => 'author_id'
 
   validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ]
   validates_presence_of :id, :on => :update
   validates_uniqueness_of :id
   validates_presence_of :visible
 
   validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ]
   validates_presence_of :id, :on => :update
   validates_uniqueness_of :id
   validates_presence_of :visible
-  validates_presence_of :date_created
 
 
-  def commenter_name
-    if self.commenter_id.nil?
-      self.read_attribute(:commenter_name)
+  def author_name
+    if self.author_id.nil?
+      self.read_attribute(:author_name)
     else
       self.user.display_name
     end
     else
       self.user.display_name
     end
index 26c236b7ad48f5550cae088a6644bc4a5b5d8093..b7cb3454d052eefa977f78be593d1384a9db6a74 100644 (file)
@@ -98,17 +98,17 @@ class Notifier < ActionMailer::Base
   def bug_comment_notification(bug_comment, recipient)
     common_headers recipient
     owner = (recipient == bug_comment.map_bug.comments.first.user);
   def bug_comment_notification(bug_comment, recipient)
     common_headers recipient
     owner = (recipient == bug_comment.map_bug.comments.first.user);
-    subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => bug_comment.commenter_name) if owner
-    subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => bug_comment.commenter_name) unless owner
+    subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => bug_comment.author_name) if owner
+    subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => bug_comment.author_name) unless owner
 
     body :bugurl => url_for(:host => SERVER_URL,
                             :controller => "browse",
                             :action => "bug",
                             :id => bug_comment.bug_id),
          :place => bug_comment.map_bug.nearby_place,
 
     body :bugurl => url_for(:host => SERVER_URL,
                             :controller => "browse",
                             :action => "bug",
                             :id => bug_comment.bug_id),
          :place => bug_comment.map_bug.nearby_place,
-         :comment => bug_comment.comment,
+         :comment => bug_comment.body,
          :owner => owner,
          :owner => owner,
-         :commenter => bug_comment.commenter_name
+         :commenter => bug_comment.author_name
   end
 
 private
   end
 
 private
index 9fd571abe6f07c4457821b9cd6ed6e7b764b5e4c..4364d108880f2920dd04f48fe8c71ccffb64ada9 100644 (file)
       <table>
         <tr>
           <th><%= t 'browse.bug.created_at' %></th>
       <table>
         <tr>
           <th><%= t 'browse.bug.created_at' %></th>
-          <td><%= l @bug.date_created %></td>
+          <td><%= l @bug.created_at %></td>
         </tr>  
        <tr>
          <th><%= t 'browse.bug.edited_at' %></th>
         </tr>  
        <tr>
          <th><%= t 'browse.bug.edited_at' %></th>
-         <td><%= l @bug.last_changed %></td>
+         <td><%= l @bug.updated_at %></td>
        </tr>
        <% if @bug.status == "closed" %>
          <tr>
            <th><%= t 'browse.bug.closed_at' %></th>
        </tr>
        <% if @bug.status == "closed" %>
          <tr>
            <th><%= t 'browse.bug.closed_at' %></th>
-           <td><%= l @bug.date_closed %></td>
+           <td><%= l @bug.closed_at %></td>
          </tr>
        <% end %>
        <tr>
          <th><%= t 'browse.bug.opened_by' %></th>
          <% if @bug.comments.first.user.nil? %>
          </tr>
        <% end %>
        <tr>
          <th><%= t 'browse.bug.opened_by' %></th>
          <% if @bug.comments.first.user.nil? %>
-           <td> <%= @bug.comments.first.commenter_name %> </td>
+           <td> <%= @bug.comments.first.author_name %> </td>
          <% else %>
            <td><%= link_to h(@bug.comments.first.user.display_name), :controller => "user", :action => "view", :display_name => @bug.comments.first.user.display_name %></td>                                  
          <% end %>
        </tr>
        <tr>
          <th><%= t 'browse.bug.description' %></th>
          <% else %>
            <td><%= link_to h(@bug.comments.first.user.display_name), :controller => "user", :action => "view", :display_name => @bug.comments.first.user.display_name %></td>                                  
          <% end %>
        </tr>
        <tr>
          <th><%= t 'browse.bug.description' %></th>
-         <td><%= h(@bug.comments.first.comment) %></td>
+         <td><%= h(@bug.comments.first.body) %></td>
        </tr>
        <tr>
          <th><%= t 'browse.node_details.coordinates' %></th>
        </tr>
        <tr>
          <th><%= t 'browse.node_details.coordinates' %></th>
           <tr>
             <td>
               <% if bug_comment.user.nil? %>
           <tr>
             <td>
               <% if bug_comment.user.nil? %>
-                <%= bug_comment.commenter_name %>
+                <%= bug_comment.author_name %>
               <% else %>
                 <%= link_to h(bug_comment.user.display_name), :controller => "user", :action => "view", :display_name => bug_comment.user.display_name %>                                      
               <% end %>
             </td>
               <% else %>
                 <%= link_to h(bug_comment.user.display_name), :controller => "user", :action => "view", :display_name => bug_comment.user.display_name %>                                      
               <% end %>
             </td>
-            <td> <%= h(bug_comment.comment) %> </td>
-            <td> <%= l bug_comment.date_created %> </td>
+            <td> <%= h(bug_comment.body) %> </td>
+            <td> <%= l bug_comment.created_at %> </td>
           </tr>
         <% end %>
       </table>
           </tr>
         <% end %>
       </table>
index abfbc56d441f9a26bb49fb212c6cd40cd3e03ffd..e928c3cacd66b086989dabcfd8a3bb4c2455bcd0 100644 (file)
@@ -12,10 +12,10 @@ xml.item do
   xml.description  htmlize(bug.flatten_comment("<br><br>"))
 
   unless bug.comments.empty?
   xml.description  htmlize(bug.flatten_comment("<br><br>"))
 
   unless bug.comments.empty?
-    xml.author bug.comments[-1].commenter_name
+    xml.author bug.comments[-1].author_name
   end
 
   end
 
-  xml.pubDate bug.last_changed.to_s(:rfc822)
+  xml.pubDate bug.updated_at.to_s(:rfc822)
   xml.geo :lat, bug.lat
   xml.geo :long, bug.lon
   xml.georss :point, "#{bug.lat} #{bug.lon}"
   xml.geo :lat, bug.lat
   xml.geo :long, bug.lon
   xml.georss :point, "#{bug.lat} #{bug.lon}"
index 32c98721e41d7d2d603eef89e9a517b10645fb17..1219f3d74ad38e70c33af3abe867491a50f2ee09 100644 (file)
@@ -1,20 +1,20 @@
 xml.bug("lon" => bug.lon, "lat" => bug.lat) do
   xml.id bug.id
 xml.bug("lon" => bug.lon, "lat" => bug.lat) do
   xml.id bug.id
-  xml.date_created bug.date_created
+  xml.date_created bug.created_at
   xml.nearby bug.nearby_place
   xml.status bug.status
 
   if bug.status == "closed"
   xml.nearby bug.nearby_place
   xml.status bug.status
 
   if bug.status == "closed"
-    xml.date_closed bug.date_closed
+    xml.date_closed bug.closed_at
   end
 
   xml.comments do
     bug.comments.each do |comment|
       xml.comment do
   end
 
   xml.comments do
     bug.comments.each do |comment|
       xml.comment do
-        xml.date comment.date_created
-        xml.uid comment.commenter_id unless comment.commenter_id.nil?
-        xml.user comment.commenter_name
-        xml.text comment.comment
+        xml.date comment.created_at
+        xml.uid comment.author_id unless comment.author_id.nil?
+        xml.user comment.author_name
+        xml.text comment.body
       end      
     end
   end
       end      
     end
   end
index 9802ae1b2d6da4cd38aac506619245fd851dad46..5e6c7152b23878d48f3bcd96b2673c07ad29cc02 100644 (file)
@@ -13,7 +13,7 @@
     <th><%= t'bugs.user.last_changed' %></th>
   </tr>
 <% @bugs.each do |bug| %>
     <th><%= t'bugs.user.last_changed' %></th>
   </tr>
 <% @bugs.each do |bug| %>
-  <tr<% if bug.comments[0].user != @user2 %> bgcolor="#EEEEEE"<% end %>>
+  <tr<% if bug.comments.first.user != @user2 %> bgcolor="#EEEEEE"<% end %>>
     <td>
       <% if bug.status == "closed" %>
         <%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
     <td>
       <% if bug.status == "closed" %>
         <%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
       <% end %>
     </td>
     <td><%= link_to bug.id.to_s, :controller => "browse", :action => "bug", :id => bug.id %></td>
       <% end %>
     </td>
     <td><%= link_to bug.id.to_s, :controller => "browse", :action => "bug", :id => bug.id %></td>
-    <% if bug.comments[0].user.nil? %> 
-      <td> <%= bug.comments[0].commenter_name %> </td> 
+    <% if bug.comments.first.user.nil? %> 
+      <td> <%= bug.comments.first.author_name %> </td> 
     <% else %> 
     <% else %> 
-      <td><%= link_to h(bug.comments[0].user.display_name), :controller => "user", :action => "view", :display_name => bug.comments[0].user.display_name %></td>
+      <td><%= link_to h(bug.comments.first.user.display_name), :controller => "user", :action => "view", :display_name => bug.comments.first.user.display_name %></td>
     <% end %>
     <% end %>
-    <td> <%= htmlize bug.comments[0].comment  %> </td> 
-    <td><%= l bug.date_created %></td>
-    <td><%= l bug.last_changed %></td>
+    <td> <%= htmlize bug.comments.first.body  %> </td> 
+    <td><%= l bug.created_at %></td>
+    <td><%= l bug.updated_at %></td>
   </tr>
 <% end %>
 </table>
   </tr>
 <% end %>
 </table>
index ced183a10b61a32367a6d8da6fbeae89a4cebc17..566a3b322c48d6651d300888e874496c8f718261 100644 (file)
@@ -27,16 +27,16 @@ xml.rss("version" => "2.0",
 
         if comment.event == "commented" and not comment.nil?
           description_text += "<b>Comment:</b><br>"
 
         if comment.event == "commented" and not comment.nil?
           description_text += "<b>Comment:</b><br>"
-          description_text += htmlize(comment.comment)
+          description_text += htmlize(comment.body)
           description_text += "<br>"
         end
 
         description_text += "<b>Full bug report:</b><br>"
           description_text += "<br>"
         end
 
         description_text += "<b>Full bug report:</b><br>"
-        description_text += comment.map_bug.flatten_comment("<br>", comment.date_created)
+        description_text += comment.map_bug.flatten_comment("<br>", comment.created_at)
 
         xml.description description_text 
 
         xml.description description_text 
-        xml.author comment.commenter_name
-        xml.pubDate comment.date_created.to_s(:rfc822)
+        xml.author comment.author_name
+        xml.pubDate comment.created_at.to_s(:rfc822)
         xml.geo :lat, comment.map_bug.lat
         xml.geo :long, comment.map_bug.lon
         xml.georss :point, "#{comment.map_bug.lat} #{comment.map_bug.lon}"
         xml.geo :lat, comment.map_bug.lat
         xml.geo :long, comment.map_bug.lon
         xml.georss :point, "#{comment.map_bug.lat} #{comment.map_bug.lon}"
diff --git a/db/migrate/20110508145337_cleanup_bug_tables.rb b/db/migrate/20110508145337_cleanup_bug_tables.rb
new file mode 100644 (file)
index 0000000..a5563ce
--- /dev/null
@@ -0,0 +1,37 @@
+class CleanupBugTables < ActiveRecord::Migration
+  def self.up
+    rename_column :map_bugs, :date_created, :created_at
+    rename_column :map_bugs, :last_changed, :updated_at
+    rename_column :map_bugs, :date_closed, :closed_at
+
+    rename_index :map_bugs, :map_bugs_tile_idx, :map_bugs_tile_staus_idx
+    rename_index :map_bugs, :map_bugs_changed_idx, :map_bugs_updated_at_idx
+    rename_index :map_bugs, :map_bugs_created_idx, :map_bugs_created_at_idx
+
+    rename_column :map_bug_comment, :date_created, :created_at
+    rename_column :map_bug_comment, :commenter_name, :author_name
+    rename_column :map_bug_comment, :commenter_ip, :author_ip
+    rename_column :map_bug_comment, :commenter_id, :author_id
+    rename_column :map_bug_comment, :comment, :body
+
+    rename_index :map_bug_comment, :map_bug_comment_id_idx, :map_bug_comment_bug_id_idx
+  end
+
+  def self.down
+    rename_index :map_bug_comment, :map_bug_comment_bug_id_idx, :map_bug_comment_id_idx
+
+    rename_column :map_bug_comment, :body, :comment
+    rename_column :map_bug_comment, :author_id, :commenter_id
+    rename_column :map_bug_comment, :author_ip, :commenter_ip
+    rename_column :map_bug_comment, :author_name, :commenter_name
+    rename_column :map_bug_comment, :created_at, :date_created
+
+    rename_index :map_bugs, :map_bugs_created_at_idx, :map_bugs_created_idx
+    rename_index :map_bugs, :map_bugs_updated_at_idx, :map_bugs_changed_idx
+    rename_index :map_bugs, :map_bugs_tile_staus_idx, :map_bugs_tile_idx
+
+    rename_column :map_bugs, :closed_at, :date_closed
+    rename_column :map_bugs, :updated_at, :last_changed
+    rename_column :map_bugs, :created_at, :date_created
+  end
+end
index 2214c07646b4c887791151bbe0ae6ed1f9928d1a..a185c01e017acdb5c32ce9b9924cf3d741e94d36 100644 (file)
@@ -2,96 +2,96 @@ t1:
   id: 1
   bug_id: 1
   visible: true
   id: 1
   bug_id: 1
   visible: true
-  date_created: 2007-01-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'This is the initial description of the bug 1'
+  created_at: 2007-01-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'This is the initial description of the bug 1'
 
 
 t2:
   id: 2
   bug_id: 2
   visible: true
 
 
 t2:
   id: 2
   bug_id: 2
   visible: true
-  date_created: 2007-01-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'This is the initial description of the bug 2'
+  created_at: 2007-01-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'This is the initial description of the bug 2'
 
 
 t3:
   id: 3
   bug_id: 2
   visible: true
 
 
 t3:
   id: 3
   bug_id: 2
   visible: true
-  date_created: 2007-02-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'This is an additional comment for bug 2'
+  created_at: 2007-02-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'This is an additional comment for bug 2'
 
 
 t4:
   id: 4
   bug_id: 3
   visible: true
 
 
 t4:
   id: 4
   bug_id: 3
   visible: true
-  date_created: 2007-01-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'This is the initial comment for bug 3'
+  created_at: 2007-01-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'This is the initial comment for bug 3'
 
 t5:
   id: 5
   bug_id: 4
   visible: true
 
 t5:
   id: 5
   bug_id: 4
   visible: true
-  date_created: 2007-01-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'Spam for bug 4'
+  created_at: 2007-01-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'Spam for bug 4'
 
 
 t6:
   id: 6
   bug_id: 5
   visible: true
 
 
 t6:
   id: 6
   bug_id: 5
   visible: true
-  date_created: 2007-01-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'Valid comment for bug 5'
+  created_at: 2007-01-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'Valid comment for bug 5'
 
 t7:
   id: 7
   bug_id: 5
   visible: false
 
 t7:
   id: 7
   bug_id: 5
   visible: false
-  date_created: 2007-02-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'Spam for bug 5'
+  created_at: 2007-02-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'Spam for bug 5'
 
 t8:
   id: 8
   bug_id: 5
   visible: true
 
 t8:
   id: 8
   bug_id: 5
   visible: true
-  date_created: 2007-02-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'Another valid comment for bug 5'
+  created_at: 2007-02-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'Another valid comment for bug 5'
 
 t9:
   id: 9
   bug_id: 6
   visible: true
 
 t9:
   id: 9
   bug_id: 6
   visible: true
-  date_created: 2007-01-01 00:00:00
+  created_at: 2007-01-01 00:00:00
   event: opened
   event: opened
-  commenter_id: 1
-  comment: 'This is a bug with from a logged-in user'
+  author_id: 1
+  body: 'This is a bug with from a logged-in user'
 
 
 t10:
   id: 10
   bug_id: 6
   visible: true
 
 
 t10:
   id: 10
   bug_id: 6
   visible: true
-  date_created: 2007-02-01 00:00:00
+  created_at: 2007-02-01 00:00:00
   event: commented
   event: commented
-  commenter_id: 4
-  comment: 'A comment from another logged-in user'
+  author_id: 4
+  body: 'A comment from another logged-in user'
 
 
 t11:
 
 
 t11:
@@ -99,10 +99,10 @@ t11:
   bug_id: 7
   visible: true
   event: opened
   bug_id: 7
   visible: true
   event: opened
-  date_created: 2007-01-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'Initial bug description'
+  created_at: 2007-01-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'Initial bug description'
 
 
 t12:
 
 
 t12:
@@ -110,18 +110,18 @@ t12:
   bug_id: 7
   visible: true
   event: commented
   bug_id: 7
   visible: true
   event: commented
-  date_created: 2007-02-01 00:00:00
-  commenter_name: 'testname'
-  commenter_ip: '192.168.1.1'
-  comment: 'A comment description'
+  created_at: 2007-02-01 00:00:00
+  author_name: 'testname'
+  author_ip: '192.168.1.1'
+  body: 'A comment description'
 
 t13:
   id: 13
   bug_id: 7
   visible: true
   event: closed
 
 t13:
   id: 13
   bug_id: 7
   visible: true
   event: closed
-  date_created: 2007-03-01 00:00:00
-  commenter_id: 4
+  created_at: 2007-03-01 00:00:00
+  author_id: 4
 
 
 
 
 
 
index 7c465ab0fc1187ffa8b6639ffae0e4bca48e25cf..92a02a6883a90b6b100153ec90656288383f8388 100644 (file)
@@ -7,8 +7,8 @@ open_bug:
   longitude: <%= 1*SCALE %>
   status: open
   tile: <%= QuadTile.tile_for_point(1,1) %>
   longitude: <%= 1*SCALE %>
   status: open
   tile: <%= QuadTile.tile_for_point(1,1) %>
-  date_created: 2007-01-01 00:00:00
-  last_changed: 2007-01-01 00:00:00
+  created_at: 2007-01-01 00:00:00
+  updated_at: 2007-01-01 00:00:00
 
 open_bug_with_comment:
   id: 2
 
 open_bug_with_comment:
   id: 2
@@ -16,8 +16,8 @@ open_bug_with_comment:
   longitude: <%= 1.1*SCALE %>
   status: open
   tile: <%= QuadTile.tile_for_point(1.1,1.1) %>
   longitude: <%= 1.1*SCALE %>
   status: open
   tile: <%= QuadTile.tile_for_point(1.1,1.1) %>
-  date_created: 2007-01-01 00:00:00
-  last_changed: 2007-02-01 00:00:00
+  created_at: 2007-01-01 00:00:00
+  updated_at: 2007-02-01 00:00:00
 
 closed_bug_with_comment:
   id: 3
 
 closed_bug_with_comment:
   id: 3
@@ -25,9 +25,9 @@ closed_bug_with_comment:
   longitude: <%= 1.2*SCALE %>
   status: closed
   tile: <%= QuadTile.tile_for_point(1.2,1.2) %>
   longitude: <%= 1.2*SCALE %>
   status: closed
   tile: <%= QuadTile.tile_for_point(1.2,1.2) %>
-  date_created: 2007-01-01 00:00:00
-  last_changed: 2007-03-01 00:00:00
-  date_closed:  2007-03-01 00:00:00
+  created_at: 2007-01-01 00:00:00
+  updated_at: 2007-03-01 00:00:00
+  closed_at:  2007-03-01 00:00:00
 
 hidden_bug_with_comment:
   id: 4
 
 hidden_bug_with_comment:
   id: 4
@@ -35,8 +35,8 @@ hidden_bug_with_comment:
   longitude: <%= 1.3*SCALE %>
   status: hidden
   tile: <%= QuadTile.tile_for_point(1.3,1.3) %>
   longitude: <%= 1.3*SCALE %>
   status: hidden
   tile: <%= QuadTile.tile_for_point(1.3,1.3) %>
-  date_created: 2007-01-01 00:00:00
-  last_changed: 2007-03-01 00:00:00
+  created_at: 2007-01-01 00:00:00
+  updated_at: 2007-03-01 00:00:00
 
 bug_with_hidden_comment:
   id: 5
 
 bug_with_hidden_comment:
   id: 5
@@ -44,8 +44,8 @@ bug_with_hidden_comment:
   longitude: <%= 1.4*SCALE %>
   status: open
   tile: <%= QuadTile.tile_for_point(1.4,1.4) %>
   longitude: <%= 1.4*SCALE %>
   status: open
   tile: <%= QuadTile.tile_for_point(1.4,1.4) %>
-  date_created: 2007-01-01 00:00:00
-  last_changed: 2007-03-01 00:00:00
+  created_at: 2007-01-01 00:00:00
+  updated_at: 2007-03-01 00:00:00
 
 bug_with_comments_by_users:
   id: 6
 
 bug_with_comments_by_users:
   id: 6
@@ -53,8 +53,8 @@ bug_with_comments_by_users:
   longitude: <%= 1.5*SCALE %>
   status: open
   tile: <%= QuadTile.tile_for_point(1.5,1.5) %>
   longitude: <%= 1.5*SCALE %>
   status: open
   tile: <%= QuadTile.tile_for_point(1.5,1.5) %>
-  date_created: 2007-01-01 00:00:00
-  last_changed: 2007-03-01 00:00:00
+  created_at: 2007-01-01 00:00:00
+  updated_at: 2007-03-01 00:00:00
 
 
 bug_closed__by_user:
 
 
 bug_closed__by_user:
@@ -63,7 +63,7 @@ bug_closed__by_user:
   longitude: <%= 1.6*SCALE %>
   status: closed
   tile: <%= QuadTile.tile_for_point(1.6,1.6) %>
   longitude: <%= 1.6*SCALE %>
   status: closed
   tile: <%= QuadTile.tile_for_point(1.6,1.6) %>
-  date_created: 2007-01-01 00:00:00
-  last_changed: 2007-03-01 00:00:00
-  date_closed:  2007-03-01 00:00:00
+  created_at: 2007-01-01 00:00:00
+  updated_at: 2007-03-01 00:00:00
+  closed_at:  2007-03-01 00:00:00
 
 
index ba47a007cdbe0b53d3d1510147ac64e97ab422c3..19c38834e15fdc388ac4d4f3abc1a381ece1a7ed 100644 (file)
@@ -15,8 +15,8 @@ class MapBugsControllerTest < ActionController::TestCase
     assert_response :success
     js = @response.body
     assert_match "\"status\":\"open\"", js
     assert_response :success
     js = @response.body
     assert_match "\"status\":\"open\"", js
-    assert_match "\"comment\":\"This is a comment\"", js
-    assert_match "\"commenter_name\":\"new_tester (a)\"", js
+    assert_match "\"body\":\"This is a comment\"", js
+    assert_match "\"author_name\":\"new_tester (a)\"", js
   end
 
   def test_map_bug_comment_create_success
   end
 
   def test_map_bug_comment_create_success
@@ -30,8 +30,8 @@ class MapBugsControllerTest < ActionController::TestCase
     js = @response.body
     assert_match "\"id\":2", js
     assert_match "\"status\":\"open\"", js
     js = @response.body
     assert_match "\"id\":2", js
     assert_match "\"status\":\"open\"", js
-    assert_match "\"comment\":\"This is an additional comment\"", js
-    assert_match "\"commenter_name\":\"new_tester2 (a)\"", js
+    assert_match "\"body\":\"This is an additional comment\"", js
+    assert_match "\"author_name\":\"new_tester2 (a)\"", js
   end
 
   def test_map_bug_read_success
   end
 
   def test_map_bug_read_success
@@ -167,8 +167,8 @@ class MapBugsControllerTest < ActionController::TestCase
     assert_response :success
     js = @response.body
     assert_match "\"id\":5", js
     assert_response :success
     js = @response.body
     assert_match "\"id\":5", js
-    assert_match "\"comment\":\"Valid comment for bug 5\"", js
-    assert_match "\"comment\":\"Another valid comment for bug 5\"", js
-    assert_no_match /\"comment\":\"Spam for bug 5\"/, js
+    assert_match "\"body\":\"Valid comment for bug 5\"", js
+    assert_match "\"body\":\"Another valid comment for bug 5\"", js
+    assert_no_match /\"body\":\"Spam for bug 5\"/, js
   end
 end
   end
 end