Commit 9b00ccf5774210f31c9a2b3954f4b7791d16ac98
- Date: Wed Apr 30 12:20:56 +0000 2008
- Committer: mtkd (mtkd@prj2.com)
- Author: mtkd (mtkd@prj2.com)
- Commit SHA1: 9b00ccf5774210f31c9a2b3954f4b7791d16ac98
- Tree SHA1: 99a69f37f2bb453444f198844cd28b92700820d3
Improved journal event entries
Commit diff
| |   |
| 13 | 13 | events.created_at, |
| 14 | 14 | coalesce(system_events.summary, |
| 15 | 15 | debug_events.summary, |
| 16 | | error_events.summary |
| 16 | error_events.summary, |
| 17 | journals.summary |
| 17 | 18 | ) AS summary |
| 18 | 19 | FROM events |
| 19 | 20 | LEFT JOIN system_events ON events.entry_type = 'system' AND events.entry_id = system_events.id |
| 20 | 21 | LEFT JOIN debug_events ON events.entry_type = 'debug' AND events.entry_id = debug_events.id |
| 21 | | LEFT JOIN error_events ON events.entry_type = 'debug' AND events.entry_id = error_events.id |
| 22 | LEFT JOIN error_events ON events.entry_type = 'error' AND events.entry_id = error_events.id |
| 23 | LEFT JOIN journals ON events.entry_type = 'journal' AND events.entry_id = journals.id |
| 22 | 24 | LEFT JOIN users ON events.user_id = users.id |
| 23 | 25 | WHERE project_id = '#{project_id}' |
| 24 | 26 | ORDER BY events.created_at DESC"] |
| toggle raw diff |
--- a/app/models/event/event.rb
+++ b/app/models/event/event.rb
@@ -13,12 +13,14 @@ class Event < ActiveRecord::Base
events.created_at,
coalesce(system_events.summary,
debug_events.summary,
- error_events.summary
+ error_events.summary,
+ journals.summary
) AS summary
FROM events
LEFT JOIN system_events ON events.entry_type = 'system' AND events.entry_id = system_events.id
LEFT JOIN debug_events ON events.entry_type = 'debug' AND events.entry_id = debug_events.id
- LEFT JOIN error_events ON events.entry_type = 'debug' AND events.entry_id = error_events.id
+ LEFT JOIN error_events ON events.entry_type = 'error' AND events.entry_id = error_events.id
+ LEFT JOIN journals ON events.entry_type = 'journal' AND events.entry_id = journals.id
LEFT JOIN users ON events.user_id = users.id
WHERE project_id = '#{project_id}'
ORDER BY events.created_at DESC"] |
| |   |
| 23 | 23 | journal.row_id = model.id |
| 24 | 24 | journal.ip = ip |
| 25 | 25 | journal.user_id = user_id |
| 26 | journal.summary = "Created new " << model.class.to_s |
| 26 | 27 | #TODO check saves okay |
| 27 | 28 | journal.save |
| 28 | | # |
| 29 | |
| 29 | 30 | for column in model.class.columns |
| 30 | 31 | #filter columns we don't want to track |
| 31 | 32 | case column.name |
| … | … | |
| 89 | 89 | journal.row_id = updated_model.id |
| 90 | 90 | journal.ip = ip |
| 91 | 91 | journal.user_id = user_id |
| 92 | journal.summary = "Updated " << model.class.to_s |
| 92 | 93 | #TODO check saves okay |
| 93 | 94 | journal.save |
| 94 | 95 | # |
| toggle raw diff |
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -23,9 +23,10 @@ class Journal < ActiveRecord::Base
journal.row_id = model.id
journal.ip = ip
journal.user_id = user_id
+ journal.summary = "Created new " << model.class.to_s
#TODO check saves okay
journal.save
- #
+
for column in model.class.columns
#filter columns we don't want to track
case column.name
@@ -88,6 +89,7 @@ class Journal < ActiveRecord::Base
journal.row_id = updated_model.id
journal.ip = ip
journal.user_id = user_id
+ journal.summary = "Updated " << model.class.to_s
#TODO check saves okay
journal.save
# |
| |   |
| 17 | 17 | # one journal entry for every create or update action |
| 18 | 18 | create_table :journals do |t| |
| 19 | 19 | t.column :model_type, :enum, :limit => [:article, :ticket, :wiki, :comment] |
| 20 | t.string :summary |
| 20 | 21 | t.integer :row_id, :references => nil # key back to the owner (e.g. article_id) |
| 21 | 22 | t.column :action, :enum, :limit => [:create, :update] |
| 22 | 23 | t.integer :user_id |
| toggle raw diff |
--- a/db/migrate/402_create_journals.rb
+++ b/db/migrate/402_create_journals.rb
@@ -17,6 +17,7 @@ class CreateJournals < ActiveRecord::Migration
# one journal entry for every create or update action
create_table :journals do |t|
t.column :model_type, :enum, :limit => [:article, :ticket, :wiki, :comment]
+ t.string :summary
t.integer :row_id, :references => nil # key back to the owner (e.g. article_id)
t.column :action, :enum, :limit => [:create, :update]
t.integer :user_id |