Merge branch 'kb_development' into kb_migration

This commit is contained in:
KMY 2023-04-10 14:14:00 +09:00
commit 139030f230
16 changed files with 61 additions and 25 deletions

View file

@ -27,6 +27,10 @@ module HasUserSettings
settings['default_sensitive']
end
def setting_public_post_to_unlisted
settings['public_post_to_unlisted']
end
def setting_unfollow_modal
settings['web.unfollow_modal']
end

View file

@ -28,6 +28,8 @@ class EmojiReaction < ApplicationRecord
has_one :notification, as: :activity, dependent: :destroy
validate :status_emoji_reactions_count
after_create :refresh_cache
after_destroy :refresh_cache
after_destroy :invalidate_cleanup_info
@ -50,4 +52,10 @@ class EmojiReaction < ApplicationRecord
query = query.where(arel_table[:id].gt(since_id)) if since_id.present?
query
end
def status_emoji_reactions_count
if status && account && status.emoji_reactions.where(account: account).count >= EMOJI_REACTION_PER_ACCOUNT_LIMIT
raise Mastodon::ValidationError, I18n.t('reactions.errors.limit_reached')
end
end
end

View file

@ -336,8 +336,8 @@ class Status < ApplicationRecord
end
def refresh_emoji_reactions_grouped_by_name!
generate_emoji_reactions_grouped_by_name.tap do |emoji_reactions|
update_status_stat!(emoji_reactions: emoji_reactions)
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)
end
end

View file

@ -4,14 +4,15 @@
#
# 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
# 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
#
class StatusStat < ApplicationRecord
@ -35,6 +36,10 @@ class StatusStat < ApplicationRecord
attributes['emoji_reactions'] || ''
end
def emoji_reactions_count
[attributes['emoji_reactions_count'], 0].max
end
private
def reset_parent_cache

View file

@ -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).to_f
observed = (status.reblogs_count + status.favourites_count + status.emoji_reactions_count * 0.3).to_f
score = if expected > observed || observed < options[:threshold]
0

View file

@ -16,6 +16,7 @@ class UserSettings
setting :default_sensitive, default: false
setting :default_privacy, default: nil
setting :default_searchability, default: :private
setting :public_post_to_unlisted, default: false
namespace :web do
setting :crop_images, default: true