Change trending hashtags to be affected be reblogs (#16164)
If a status with a hashtag becomes very popular, it stands to reason that the hashtag should have a chance at trending Fix no stats being recorded for hashtags that are not allowed to trend, and stop ignoring bots Remove references to hashtags in profile directory from the code and the admin UImain
parent
2c77d97e0d
commit
74081433d0
@ -1,24 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: account_tag_stats
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# tag_id :bigint(8) not null
|
||||
# accounts_count :bigint(8) default(0), not null
|
||||
# hidden :boolean default(FALSE), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class AccountTagStat < ApplicationRecord
|
||||
belongs_to :tag, inverse_of: :account_tag_stat
|
||||
|
||||
def increment_count!(key)
|
||||
update(key => public_send(key) + 1)
|
||||
end
|
||||
|
||||
def decrement_count!(key)
|
||||
update(key => [public_send(key) - 1, 0].max)
|
||||
end
|
||||
end
|
@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DropAccountTagStats < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
drop_table :account_tag_stats
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
@ -1,38 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountTagStat, type: :model do
|
||||
key = 'accounts_count'
|
||||
let(:account_tag_stat) { Fabricate(:tag).account_tag_stat }
|
||||
|
||||
describe '#increment_count!' do
|
||||
it 'calls #update' do
|
||||
args = { key => account_tag_stat.public_send(key) + 1 }
|
||||
expect(account_tag_stat).to receive(:update).with(args)
|
||||
account_tag_stat.increment_count!(key)
|
||||
end
|
||||
|
||||
it 'increments value by 1' do
|
||||
expect do
|
||||
account_tag_stat.increment_count!(key)
|
||||
end.to change { account_tag_stat.accounts_count }.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#decrement_count!' do
|
||||
it 'calls #update' do
|
||||
args = { key => [account_tag_stat.public_send(key) - 1, 0].max }
|
||||
expect(account_tag_stat).to receive(:update).with(args)
|
||||
account_tag_stat.decrement_count!(key)
|
||||
end
|
||||
|
||||
it 'decrements value by 1' do
|
||||
account_tag_stat.update(key => 1)
|
||||
|
||||
expect do
|
||||
account_tag_stat.decrement_count!(key)
|
||||
end.to change { account_tag_stat.accounts_count }.by(-1)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue