diff --git a/app/models/status.rb b/app/models/status.rb index f0529e0410..abf31c2dcf 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -318,8 +318,8 @@ class Status < ApplicationRecord status_stat&.emoji_reactions_count || 0 end - def emoji_reactions_count_per_account - status_stat&.emoji_reactions_count_per_account || 0 + def emoji_reaction_accounts_count + status_stat&.emoji_reaction_accounts_count || 0 end def increment_count!(key) @@ -349,7 +349,7 @@ class Status < ApplicationRecord def refresh_emoji_reactions_grouped_by_name! generate_emoji_reactions_grouped_by_name.tap do |emoji_reactions_json| - update_status_stat!(emoji_reactions: emoji_reactions_json, emoji_reactions_count: emoji_reactions.size, emoji_reactions_count_per_account: emoji_reactions.map(&:account_id).uniq.size) + update_status_stat!(emoji_reactions: emoji_reactions_json, emoji_reactions_count: emoji_reactions.size, emoji_reaction_accounts_count: emoji_reactions.map(&:account_id).uniq.size) end end diff --git a/app/models/status_stat.rb b/app/models/status_stat.rb index cdee95855b..107f8339d6 100644 --- a/app/models/status_stat.rb +++ b/app/models/status_stat.rb @@ -4,17 +4,17 @@ # # Table name: status_stats # -# id :bigint(8) not null, primary key -# status_id :bigint(8) not null -# replies_count :bigint(8) default(0), not null -# reblogs_count :bigint(8) default(0), not null -# favourites_count :bigint(8) default(0), not null -# created_at :datetime not null -# updated_at :datetime not null -# emoji_reactions :string -# emoji_reactions_count :integer default(0), not null -# test :integer default(0), not null -# emoji_reactions_count_per_account :integer default(0), not null +# id :bigint(8) not null, primary key +# status_id :bigint(8) not null +# replies_count :bigint(8) default(0), not null +# reblogs_count :bigint(8) default(0), not null +# favourites_count :bigint(8) default(0), not null +# created_at :datetime not null +# updated_at :datetime not null +# emoji_reactions :string +# emoji_reactions_count :integer default(0), not null +# test :integer default(0), not null +# emoji_reaction_accounts_count :integer default(0), not null # class StatusStat < ApplicationRecord @@ -42,8 +42,8 @@ class StatusStat < ApplicationRecord [attributes['emoji_reactions_count'], 0].max end - def emoji_reactions_count_per_account - [attributes['emoji_reactions_count_per_account'], 0].max + def emoji_reaction_accounts_count + [attributes['emoji_reaction_accounts_count'], 0].max end private diff --git a/app/models/trends/statuses.rb b/app/models/trends/statuses.rb index d808b817be..79c7887372 100644 --- a/app/models/trends/statuses.rb +++ b/app/models/trends/statuses.rb @@ -97,7 +97,7 @@ class Trends::Statuses < Trends::Base def calculate_scores(statuses, at_time) items = statuses.map do |status| expected = 1.0 - observed = (status.reblogs_count + status.favourites_count + status.emoji_reactions_count_per_account * 0.8).to_f + observed = (status.reblogs_count + status.favourites_count + status.emoji_reaction_accounts_count * 0.8).to_f score = if expected > observed || observed < options[:threshold] 0 diff --git a/db/migrate/20230414010523_add_emoji_reactions_count_per_account_to_status_stats.rb b/db/migrate/20230414010523_add_emoji_reactions_count_per_account_to_status_stats.rb index 8a3eba8b2c..e7958f62dc 100644 --- a/db/migrate/20230414010523_add_emoji_reactions_count_per_account_to_status_stats.rb +++ b/db/migrate/20230414010523_add_emoji_reactions_count_per_account_to_status_stats.rb @@ -1,5 +1,5 @@ class AddEmojiReactionsCountPerAccountToStatusStats < ActiveRecord::Migration[6.1] def change - add_column :status_stats, :emoji_reactions_count_per_account, :integer, null: false, default: 0 + add_column :status_stats, :emoji_reaction_accounts_count, :integer, null: false, default: 0 end end diff --git a/db/schema.rb b/db/schema.rb index 02b1025332..82581d71e5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -936,7 +936,7 @@ ActiveRecord::Schema.define(version: 2023_04_14_010523) do t.string "emoji_reactions" t.integer "emoji_reactions_count", default: 0, null: false t.integer "test", default: 0, null: false - t.integer "emoji_reactions_count_per_account", default: 0, null: false + t.integer "emoji_reaction_accounts_count", default: 0, null: false t.index ["status_id"], name: "index_status_stats_on_status_id", unique: true end