Merge pull request #240 from Retrospring/add-indexes-to-notifications

Add indexes to notifications table
This commit is contained in:
Karina Kwiatek 2021-12-28 16:12:37 +01:00 committed by GitHub
commit 52ece6fa5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 9 deletions

View File

@ -0,0 +1,6 @@
class AddIndexesToNotifications < ActiveRecord::Migration[5.2]
def change
add_index :notifications, :recipient_id
add_index :notifications, :new
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_12_19_153054) do ActiveRecord::Schema.define(version: 2021_12_28_135426) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -114,6 +114,8 @@ ActiveRecord::Schema.define(version: 2021_12_19_153054) do
t.boolean "new" t.boolean "new"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.index ["new"], name: "index_notifications_on_new"
t.index ["recipient_id"], name: "index_notifications_on_recipient_id"
end end
create_table "profiles", force: :cascade do |t| create_table "profiles", force: :cascade do |t|
@ -257,12 +259,7 @@ ActiveRecord::Schema.define(version: 2021_12_19_153054) do
t.integer "asked_count", default: 0, null: false t.integer "asked_count", default: 0, null: false
t.integer "answered_count", default: 0, null: false t.integer "answered_count", default: 0, null: false
t.integer "commented_count", default: 0, null: false t.integer "commented_count", default: 0, null: false
t.string "display_name"
t.integer "smiled_count", default: 0, null: false t.integer "smiled_count", default: 0, null: false
t.string "motivation_header", default: "", null: false
t.string "website", default: "", null: false
t.string "location", default: "", null: false
t.text "bio", default: "", null: false
t.string "profile_picture_file_name" t.string "profile_picture_file_name"
t.boolean "profile_picture_processing" t.boolean "profile_picture_processing"
t.integer "profile_picture_x" t.integer "profile_picture_x"

View File

@ -100,8 +100,9 @@ EOS
describe "#answer_opengraph" do describe "#answer_opengraph" do
context "sample user and answer" do context "sample user and answer" do
let!(:user) { FactoryBot.create(:user, let!(:user) { FactoryBot.create(:user,
profile: {
display_name: '', display_name: '',
bio: 'A bunch of raccoons in a trenchcoat.', description: 'A bunch of raccoons in a trenchcoat.'},
screen_name: 'raccoons') } screen_name: 'raccoons') }
let(:answer) { FactoryBot.create(:answer, let(:answer) { FactoryBot.create(:answer,
user_id: user.id,) } user_id: user.id,) }

View File

@ -12,6 +12,7 @@ RSpec.describe User, type: :model do
password: 'y_u_no_secure_password?', password: 'y_u_no_secure_password?',
email: 'nice.meme@nsa.gov' email: 'nice.meme@nsa.gov'
) )
Profile.new(user: @user)
end end
subject { @user } subject { @user }
@ -23,7 +24,7 @@ RSpec.describe User, type: :model do
end end
it '#motivation_header has a default value' do it '#motivation_header has a default value' do
expect(@user.motivation_header).to match '' expect(@user.profile.motivation_header).to match ''
end end
it 'does not save an invalid screen name' do it 'does not save an invalid screen name' do