Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Memberships indices and User#login index.

Eager load user SSH keys.
  • Loading branch information...
commit 25c68f546778a272227c65b7be626aa786a1e85e 1 parent 3be8422
@nbibler nbibler authored
View
4 app/controllers/users_controller.rb
@@ -2,7 +2,7 @@ class UsersController < ApplicationController
def index
@project = Project.find(params[:project_id])
- @users = @project.users
+ @users = @project.users.includes(:ssh_keys)
respond_to do |format|
format.yaml { render :text => @users.collect { |u| u.keymaster_data }.to_yaml }
@@ -11,7 +11,7 @@ def index
def show
@parent = params.has_key?(:project_id) ? Project.find(params[:project_id]).users : User
- @user = @parent.find_by_login(params[:id]) || raise(ActiveRecord::RecordNotFound)
+ @user = @parent.where(:login => params[:id]).includes(:ssh_keys).first || raise(ActiveRecord::RecordNotFound)
respond_to do |format|
format.yaml { render :text => @user.keymaster_data.to_yaml }
View
11 db/migrate/20110404014622_add_indices_to_memberships.rb
@@ -0,0 +1,11 @@
+class AddIndicesToMemberships < ActiveRecord::Migration
+ def self.up
+ add_index :memberships, :project_id
+ add_index :memberships, :user_id
+ end
+
+ def self.down
+ remove_index :memberships, :user_id
+ remove_index :memberships, :project_id
+ end
+end
View
9 db/migrate/20110404015102_add_login_index_to_users.rb
@@ -0,0 +1,9 @@
+class AddLoginIndexToUsers < ActiveRecord::Migration
+ def self.up
+ add_index :users, :login, :unique => true
+ end
+
+ def self.down
+ remove_index :users, :login
+ end
+end
View
7 db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110404013217) do
+ActiveRecord::Schema.define(:version => 20110404015102) do
create_table "memberships", :force => true do |t|
t.integer "project_id"
@@ -19,6 +19,9 @@
t.datetime "updated_at"
end
+ add_index "memberships", ["project_id"], :name => "index_memberships_on_project_id"
+ add_index "memberships", ["user_id"], :name => "index_memberships_on_user_id"
+
create_table "projects", :force => true do |t|
t.string "name"
t.datetime "created_at"
@@ -57,4 +60,6 @@
t.datetime "updated_at"
end
+ add_index "users", ["login"], :name => "index_users_on_login", :unique => true
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.