Skip to content

Commit f883147

Browse files
committed
Add index to Repo
1 parent d3296cf commit f883147

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

app/models/repo.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ def weight
115115
end
116116
end
117117

118-
def subscriber_count
119-
users.count
120-
end
121-
122118
# pulls out number of issues divided by number of subscribers
123119
def self.order_by_need
124120
joins(:repo_subscriptions)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddIndexSubscriberCount < ActiveRecord::Migration[7.0]
2+
def change
3+
add_index :repos, :subscribers_count
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.0].define(version: 2022_10_13_212959) do
13+
ActiveRecord::Schema[7.0].define(version: 2022_12_28_065556) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "pg_stat_statements"
1616
enable_extension "plpgsql"
@@ -161,6 +161,7 @@
161161
t.index ["issues_count"], name: "index_repos_on_issues_count"
162162
t.index ["language"], name: "index_repos_on_language"
163163
t.index ["name", "user_name"], name: "index_repos_on_name_and_user_name", unique: true
164+
t.index ["subscribers_count"], name: "index_repos_on_subscribers_count"
164165
t.index ["user_name"], name: "index_repos_on_user_name"
165166
end
166167

0 commit comments

Comments
 (0)