Commit ae2233b1149392d63c6fa4ede8a58b7d82d7790c
1 parent
0f2798d4
Exists in
master
and in
4 other branches
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 | 151 | end |
| 152 | 152 | |
| 153 | 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 | 156 | else |
| 158 | 157 | "Never" |
| 159 | 158 | end | ... | ... |
db/schema.rb
| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | # It's strongly recommended to check this file into your version control system. |
| 13 | 13 | |
| 14 | 14 | ActiveRecord::Schema.define(:version => 20130404164628) do |
| 15 | + | |
| 15 | 16 | create_table "events", :force => true do |t| |
| 16 | 17 | t.string "target_type" |
| 17 | 18 | t.integer "target_id" |
| ... | ... | @@ -36,8 +37,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 36 | 37 | t.integer "assignee_id" |
| 37 | 38 | t.integer "author_id" |
| 38 | 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 | 42 | t.integer "position", :default => 0 |
| 42 | 43 | t.string "branch_name" |
| 43 | 44 | t.text "description" |
| ... | ... | @@ -54,8 +55,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 54 | 55 | |
| 55 | 56 | create_table "keys", :force => true do |t| |
| 56 | 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 | 60 | t.text "key" |
| 60 | 61 | t.string "title" |
| 61 | 62 | t.string "identifier" |
| ... | ... | @@ -73,8 +74,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 73 | 74 | t.integer "author_id" |
| 74 | 75 | t.integer "assignee_id" |
| 75 | 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 | 79 | t.text "st_commits", :limit => 2147483647 |
| 79 | 80 | t.text "st_diffs", :limit => 2147483647 |
| 80 | 81 | t.integer "milestone_id" |
| ... | ... | @@ -123,8 +124,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 123 | 124 | t.text "note" |
| 124 | 125 | t.string "noteable_type" |
| 125 | 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 | 129 | t.integer "project_id" |
| 129 | 130 | t.string "attachment" |
| 130 | 131 | t.string "line_code" |
| ... | ... | @@ -142,8 +143,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 142 | 143 | t.string "name" |
| 143 | 144 | t.string "path" |
| 144 | 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 | 148 | t.integer "creator_id" |
| 148 | 149 | t.string "default_branch" |
| 149 | 150 | t.boolean "issues_enabled", :default => true, :null => false |
| ... | ... | @@ -187,8 +188,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 187 | 188 | t.text "content" |
| 188 | 189 | t.integer "author_id", :null => false |
| 189 | 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 | 193 | t.string "file_name" |
| 193 | 194 | t.datetime "expires_at" |
| 194 | 195 | end |
| ... | ... | @@ -207,9 +208,6 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 207 | 208 | t.datetime "created_at" |
| 208 | 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 | 211 | create_table "tags", :force => true do |t| |
| 214 | 212 | t.string "name" |
| 215 | 213 | end |
| ... | ... | @@ -241,42 +239,41 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 241 | 239 | end |
| 242 | 240 | |
| 243 | 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 | 244 | t.string "reset_password_token" |
| 247 | 245 | t.datetime "reset_password_sent_at" |
| 248 | 246 | t.datetime "remember_created_at" |
| 249 | - t.integer "sign_in_count", :default => 0 | |
| 247 | + t.integer "sign_in_count", :default => 0 | |
| 250 | 248 | t.datetime "current_sign_in_at" |
| 251 | 249 | t.datetime "last_sign_in_at" |
| 252 | 250 | t.string "current_sign_in_ip" |
| 253 | 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 | 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 | 260 | t.string "authentication_token" |
| 263 | - t.integer "theme_id", :default => 1, :null => false | |
| 261 | + t.integer "theme_id", :default => 1, :null => false | |
| 264 | 262 | t.string "bio" |
| 265 | - t.integer "failed_attempts", :default => 0 | |
| 263 | + t.integer "failed_attempts", :default => 0 | |
| 266 | 264 | t.datetime "locked_at" |
| 267 | 265 | t.string "extern_uid" |
| 268 | 266 | t.string "provider" |
| 269 | 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 | 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 | 273 | end |
| 276 | 274 | |
| 277 | 275 | add_index "users", ["admin"], :name => "index_users_on_admin" |
| 278 | 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 | 277 | add_index "users", ["name"], :name => "index_users_on_name" |
| 281 | 278 | add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true |
| 282 | 279 | add_index "users", ["username"], :name => "index_users_on_username" |
| ... | ... | @@ -284,8 +281,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 284 | 281 | create_table "users_projects", :force => true do |t| |
| 285 | 282 | t.integer "user_id", :null => false |
| 286 | 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 | 286 | t.integer "project_access", :default => 0, :null => false |
| 290 | 287 | t.integer "notification_level", :default => 3, :null => false |
| 291 | 288 | end |
| ... | ... | @@ -297,8 +294,8 @@ ActiveRecord::Schema.define(:version => 20130404164628) do |
| 297 | 294 | create_table "web_hooks", :force => true do |t| |
| 298 | 295 | t.string "url" |
| 299 | 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 | 299 | t.string "type", :default => "ProjectHook" |
| 303 | 300 | t.integer "service_id" |
| 304 | 301 | end | ... | ... |