Change hashtag trends to be stored in the database instead of redis (#32837)
Co-authored-by: David Roetzel <david@roetzel.de>
This commit is contained in:
parent
b9b26490e7
commit
48ea7552dd
18 changed files with 195 additions and 157 deletions
5
spec/fabricators/tag_trend_fabricator.rb
Normal file
5
spec/fabricators/tag_trend_fabricator.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:tag_trend) do
|
||||
tag
|
||||
end
|
|
@ -71,6 +71,7 @@ RSpec.describe AdminMailer do
|
|||
before do
|
||||
PreviewCardTrend.create!(preview_card: link)
|
||||
StatusTrend.create!(status: status, account: Fabricate(:account))
|
||||
TagTrend.create!(tag: tag)
|
||||
recipient.user.update(locale: :en)
|
||||
end
|
||||
|
||||
|
|
11
spec/models/tag_trend_spec.rb
Normal file
11
spec/models/tag_trend_spec.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe TagTrend do
|
||||
include_examples 'RankedTrend'
|
||||
|
||||
describe 'Associations' do
|
||||
it { is_expected.to belong_to(:tag).required }
|
||||
end
|
||||
end
|
|
@ -61,10 +61,10 @@ RSpec.describe Trends::Tags do
|
|||
|
||||
it 'decays scores' do
|
||||
subject.refresh(yesterday + 12.hours)
|
||||
original_score = subject.score(tag_ocs.id)
|
||||
original_score = TagTrend.find_by(tag: tag_ocs).score
|
||||
expect(original_score).to eq 144.0
|
||||
subject.refresh(yesterday + 12.hours + subject.options[:max_score_halflife])
|
||||
decayed_score = subject.score(tag_ocs.id)
|
||||
decayed_score = TagTrend.find_by(tag: tag_ocs).score
|
||||
expect(decayed_score).to be <= original_score / 2
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue