Commit ae2233b1149392d63c6fa4ede8a58b7d82d7790c

Authored by Dmitriy Zaporozhets
1 parent 0f2798d4

Improve perfomance by using project.last_activity_at in project_last_activity helper

Showing 2 changed files with 35 additions and 39 deletions   Show diff stats
app/helpers/application_helper.rb
@@ -151,9 +151,8 @@ module ApplicationHelper @@ -151,9 +151,8 @@ module ApplicationHelper
151 end 151 end
152 152
153 def project_last_activity project 153 def project_last_activity project
154 - activity = project.last_activity  
155 - if activity && activity.created_at  
156 - time_ago_in_words(activity.created_at) + " ago" 154 + if project.last_activity_at
  155 + time_ago_in_words(project.last_activity_at) + " ago"
157 else 156 else
158 "Never" 157 "Never"
159 end 158 end
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 # It's strongly recommended to check this file into your version control system. 12 # It's strongly recommended to check this file into your version control system.
13 13
14 ActiveRecord::Schema.define(:version => 20130404164628) do 14 ActiveRecord::Schema.define(:version => 20130404164628) do
  15 +
15 create_table "events", :force => true do |t| 16 create_table "events", :force => true do |t|
16 t.string "target_type" 17 t.string "target_type"
17 t.integer "target_id" 18 t.integer "target_id"
@@ -36,8 +37,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -36,8 +37,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
36 t.integer "assignee_id" 37 t.integer "assignee_id"
37 t.integer "author_id" 38 t.integer "author_id"
38 t.integer "project_id" 39 t.integer "project_id"
39 - t.datetime "created_at", :null => false  
40 - t.datetime "updated_at", :null => false 40 + t.datetime "created_at"
  41 + t.datetime "updated_at"
41 t.integer "position", :default => 0 42 t.integer "position", :default => 0
42 t.string "branch_name" 43 t.string "branch_name"
43 t.text "description" 44 t.text "description"
@@ -54,8 +55,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -54,8 +55,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
54 55
55 create_table "keys", :force => true do |t| 56 create_table "keys", :force => true do |t|
56 t.integer "user_id" 57 t.integer "user_id"
57 - t.datetime "created_at", :null => false  
58 - t.datetime "updated_at", :null => false 58 + t.datetime "created_at"
  59 + t.datetime "updated_at"
59 t.text "key" 60 t.text "key"
60 t.string "title" 61 t.string "title"
61 t.string "identifier" 62 t.string "identifier"
@@ -73,8 +74,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -73,8 +74,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
73 t.integer "author_id" 74 t.integer "author_id"
74 t.integer "assignee_id" 75 t.integer "assignee_id"
75 t.string "title" 76 t.string "title"
76 - t.datetime "created_at", :null => false  
77 - t.datetime "updated_at", :null => false 77 + t.datetime "created_at"
  78 + t.datetime "updated_at"
78 t.text "st_commits", :limit => 2147483647 79 t.text "st_commits", :limit => 2147483647
79 t.text "st_diffs", :limit => 2147483647 80 t.text "st_diffs", :limit => 2147483647
80 t.integer "milestone_id" 81 t.integer "milestone_id"
@@ -123,8 +124,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -123,8 +124,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
123 t.text "note" 124 t.text "note"
124 t.string "noteable_type" 125 t.string "noteable_type"
125 t.integer "author_id" 126 t.integer "author_id"
126 - t.datetime "created_at", :null => false  
127 - t.datetime "updated_at", :null => false 127 + t.datetime "created_at"
  128 + t.datetime "updated_at"
128 t.integer "project_id" 129 t.integer "project_id"
129 t.string "attachment" 130 t.string "attachment"
130 t.string "line_code" 131 t.string "line_code"
@@ -142,8 +143,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -142,8 +143,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
142 t.string "name" 143 t.string "name"
143 t.string "path" 144 t.string "path"
144 t.text "description" 145 t.text "description"
145 - t.datetime "created_at", :null => false  
146 - t.datetime "updated_at", :null => false 146 + t.datetime "created_at"
  147 + t.datetime "updated_at"
147 t.integer "creator_id" 148 t.integer "creator_id"
148 t.string "default_branch" 149 t.string "default_branch"
149 t.boolean "issues_enabled", :default => true, :null => false 150 t.boolean "issues_enabled", :default => true, :null => false
@@ -187,8 +188,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -187,8 +188,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
187 t.text "content" 188 t.text "content"
188 t.integer "author_id", :null => false 189 t.integer "author_id", :null => false
189 t.integer "project_id", :null => false 190 t.integer "project_id", :null => false
190 - t.datetime "created_at", :null => false  
191 - t.datetime "updated_at", :null => false 191 + t.datetime "created_at"
  192 + t.datetime "updated_at"
192 t.string "file_name" 193 t.string "file_name"
193 t.datetime "expires_at" 194 t.datetime "expires_at"
194 end 195 end
@@ -207,9 +208,6 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -207,9 +208,6 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
207 t.datetime "created_at" 208 t.datetime "created_at"
208 end 209 end
209 210
210 - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"  
211 - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"  
212 -  
213 create_table "tags", :force => true do |t| 211 create_table "tags", :force => true do |t|
214 t.string "name" 212 t.string "name"
215 end 213 end
@@ -241,42 +239,41 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -241,42 +239,41 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
241 end 239 end
242 240
243 create_table "users", :force => true do |t| 241 create_table "users", :force => true do |t|
244 - t.string "email", :default => "", :null => false  
245 - t.string "encrypted_password", :default => "", :null => false 242 + t.string "email", :default => "", :null => false
  243 + t.string "encrypted_password", :limit => 128, :default => "", :null => false
246 t.string "reset_password_token" 244 t.string "reset_password_token"
247 t.datetime "reset_password_sent_at" 245 t.datetime "reset_password_sent_at"
248 t.datetime "remember_created_at" 246 t.datetime "remember_created_at"
249 - t.integer "sign_in_count", :default => 0 247 + t.integer "sign_in_count", :default => 0
250 t.datetime "current_sign_in_at" 248 t.datetime "current_sign_in_at"
251 t.datetime "last_sign_in_at" 249 t.datetime "last_sign_in_at"
252 t.string "current_sign_in_ip" 250 t.string "current_sign_in_ip"
253 t.string "last_sign_in_ip" 251 t.string "last_sign_in_ip"
254 - t.datetime "created_at", :null => false  
255 - t.datetime "updated_at", :null => false 252 + t.datetime "created_at"
  253 + t.datetime "updated_at"
256 t.string "name" 254 t.string "name"
257 - t.boolean "admin", :default => false, :null => false  
258 - t.integer "projects_limit", :default => 10  
259 - t.string "skype", :default => "", :null => false  
260 - t.string "linkedin", :default => "", :null => false  
261 - t.string "twitter", :default => "", :null => false 255 + t.boolean "admin", :default => false, :null => false
  256 + t.integer "projects_limit", :default => 10
  257 + t.string "skype", :default => "", :null => false
  258 + t.string "linkedin", :default => "", :null => false
  259 + t.string "twitter", :default => "", :null => false
262 t.string "authentication_token" 260 t.string "authentication_token"
263 - t.integer "theme_id", :default => 1, :null => false 261 + t.integer "theme_id", :default => 1, :null => false
264 t.string "bio" 262 t.string "bio"
265 - t.integer "failed_attempts", :default => 0 263 + t.integer "failed_attempts", :default => 0
266 t.datetime "locked_at" 264 t.datetime "locked_at"
267 t.string "extern_uid" 265 t.string "extern_uid"
268 t.string "provider" 266 t.string "provider"
269 t.string "username" 267 t.string "username"
270 - t.boolean "can_create_group", :default => true, :null => false  
271 - t.boolean "can_create_team", :default => true, :null => false 268 + t.boolean "can_create_group", :default => true, :null => false
  269 + t.boolean "can_create_team", :default => true, :null => false
272 t.string "state" 270 t.string "state"
273 - t.integer "color_scheme_id", :default => 1, :null => false  
274 - t.integer "notification_level", :default => 1, :null => false 271 + t.integer "color_scheme_id", :default => 1, :null => false
  272 + t.integer "notification_level", :default => 1, :null => false
275 end 273 end
276 274
277 add_index "users", ["admin"], :name => "index_users_on_admin" 275 add_index "users", ["admin"], :name => "index_users_on_admin"
278 add_index "users", ["email"], :name => "index_users_on_email", :unique => true 276 add_index "users", ["email"], :name => "index_users_on_email", :unique => true
279 - add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true  
280 add_index "users", ["name"], :name => "index_users_on_name" 277 add_index "users", ["name"], :name => "index_users_on_name"
281 add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true 278 add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
282 add_index "users", ["username"], :name => "index_users_on_username" 279 add_index "users", ["username"], :name => "index_users_on_username"
@@ -284,8 +281,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -284,8 +281,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
284 create_table "users_projects", :force => true do |t| 281 create_table "users_projects", :force => true do |t|
285 t.integer "user_id", :null => false 282 t.integer "user_id", :null => false
286 t.integer "project_id", :null => false 283 t.integer "project_id", :null => false
287 - t.datetime "created_at", :null => false  
288 - t.datetime "updated_at", :null => false 284 + t.datetime "created_at"
  285 + t.datetime "updated_at"
289 t.integer "project_access", :default => 0, :null => false 286 t.integer "project_access", :default => 0, :null => false
290 t.integer "notification_level", :default => 3, :null => false 287 t.integer "notification_level", :default => 3, :null => false
291 end 288 end
@@ -297,8 +294,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do @@ -297,8 +294,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do
297 create_table "web_hooks", :force => true do |t| 294 create_table "web_hooks", :force => true do |t|
298 t.string "url" 295 t.string "url"
299 t.integer "project_id" 296 t.integer "project_id"
300 - t.datetime "created_at", :null => false  
301 - t.datetime "updated_at", :null => false 297 + t.datetime "created_at"
  298 + t.datetime "updated_at"
302 t.string "type", :default => "ProjectHook" 299 t.string "type", :default => "ProjectHook"
303 t.integer "service_id" 300 t.integer "service_id"
304 end 301 end