mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Store EmailLog#reply_key
as uuid
data type.
This commit is contained in:
parent
22dad7f0e8
commit
3553375dd2
@ -71,6 +71,10 @@ class EmailLog < ActiveRecord::Base
|
|||||||
super&.delete('-')
|
super&.delete('-')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reply_key
|
||||||
|
super&.delete('-')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
@ -83,7 +87,7 @@ end
|
|||||||
# user_id :integer
|
# user_id :integer
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# reply_key :string(32)
|
# reply_key :uuid
|
||||||
# post_id :integer
|
# post_id :integer
|
||||||
# topic_id :integer
|
# topic_id :integer
|
||||||
# skipped :boolean default(FALSE)
|
# skipped :boolean default(FALSE)
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
class AlterReplyKeyOnEmailLogs < ActiveRecord::Migration[5.2]
|
||||||
|
def up
|
||||||
|
change_column :email_logs, :reply_key, 'uuid USING reply_key::uuid'
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
change_column :email_logs, :reply_key, :string
|
||||||
|
end
|
||||||
|
end
|
@ -101,19 +101,20 @@ describe EmailLog do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#bounce_key' do
|
%w{reply_key bounce_key}.each do |key|
|
||||||
it 'should format the bounce key correctly' do
|
describe "##{key}" do
|
||||||
bounce_key = SecureRandom.hex
|
it "should format the #{key} correctly" do
|
||||||
email_log = Fabricate(:email_log, user: user, bounce_key: bounce_key)
|
hex = SecureRandom.hex
|
||||||
|
email_log = Fabricate(:email_log, user: user, "#{key}": hex)
|
||||||
|
|
||||||
raw_bounce_key = EmailLog.where(id: email_log.id)
|
raw_key = EmailLog.where(id: email_log.id)
|
||||||
.pluck("bounce_key::text")
|
.pluck("#{key}::text")
|
||||||
.first
|
.first
|
||||||
|
|
||||||
expect(raw_bounce_key).to_not eq(bounce_key)
|
expect(raw_key).to_not eq(hex)
|
||||||
expect(raw_bounce_key.delete('-')).to eq(bounce_key)
|
expect(raw_key.delete('-')).to eq(hex)
|
||||||
expect(EmailLog.find(email_log.id).bounce_key).to eq(bounce_key)
|
expect(EmailLog.find(email_log.id).send(key)).to eq(hex)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user