Merge commit 'fed859a7d6
' into kb_migration
This commit is contained in:
commit
d52daef203
9 changed files with 42 additions and 13 deletions
|
@ -28,6 +28,7 @@ class EmojiReaction < ApplicationRecord
|
||||||
|
|
||||||
has_one :notification, as: :activity, dependent: :destroy
|
has_one :notification, as: :activity, dependent: :destroy
|
||||||
|
|
||||||
|
validate :status_same_emoji_reaction
|
||||||
validate :status_emoji_reactions_count
|
validate :status_emoji_reactions_count
|
||||||
|
|
||||||
after_create :refresh_cache
|
after_create :refresh_cache
|
||||||
|
@ -53,6 +54,12 @@ class EmojiReaction < ApplicationRecord
|
||||||
query
|
query
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def status_same_emoji_reaction
|
||||||
|
if status && account && status.emoji_reactions.where(account: account).where(name: name).where(custom_emoji_id: custom_emoji_id).any?
|
||||||
|
raise Mastodon::ValidationError, I18n.t('reactions.errors.duplication')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def status_emoji_reactions_count
|
def status_emoji_reactions_count
|
||||||
if status && account && status.emoji_reactions.where(account: account).count >= EMOJI_REACTION_PER_ACCOUNT_LIMIT
|
if status && account && status.emoji_reactions.where(account: account).count >= EMOJI_REACTION_PER_ACCOUNT_LIMIT
|
||||||
raise Mastodon::ValidationError, I18n.t('reactions.errors.limit_reached')
|
raise Mastodon::ValidationError, I18n.t('reactions.errors.limit_reached')
|
||||||
|
|
|
@ -315,6 +315,10 @@ class Status < ApplicationRecord
|
||||||
status_stat&.emoji_reactions_count || 0
|
status_stat&.emoji_reactions_count || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def emoji_reactions_count_per_account
|
||||||
|
status_stat&.emoji_reactions_count_per_account || 0
|
||||||
|
end
|
||||||
|
|
||||||
def increment_count!(key)
|
def increment_count!(key)
|
||||||
update_status_stat!(key => public_send(key) + 1)
|
update_status_stat!(key => public_send(key) + 1)
|
||||||
end
|
end
|
||||||
|
@ -342,7 +346,7 @@ class Status < ApplicationRecord
|
||||||
|
|
||||||
def refresh_emoji_reactions_grouped_by_name!
|
def refresh_emoji_reactions_grouped_by_name!
|
||||||
generate_emoji_reactions_grouped_by_name.tap do |emoji_reactions_json|
|
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)
|
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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
# emoji_reactions :string
|
# emoji_reactions :string
|
||||||
# emoji_reactions_count :integer default(0), not null
|
# emoji_reactions_count :integer default(0), not null
|
||||||
# test :integer default(0), not null
|
# test :integer default(0), not null
|
||||||
|
# emoji_reactions_count_per_account :integer default(0), not null
|
||||||
#
|
#
|
||||||
|
|
||||||
class StatusStat < ApplicationRecord
|
class StatusStat < ApplicationRecord
|
||||||
|
@ -41,6 +42,10 @@ class StatusStat < ApplicationRecord
|
||||||
[attributes['emoji_reactions_count'], 0].max
|
[attributes['emoji_reactions_count'], 0].max
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def emoji_reactions_count_per_account
|
||||||
|
[attributes['emoji_reactions_count_per_account'], 0].max
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def reset_parent_cache
|
def reset_parent_cache
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Trends::Statuses < Trends::Base
|
||||||
def calculate_scores(statuses, at_time)
|
def calculate_scores(statuses, at_time)
|
||||||
items = statuses.map do |status|
|
items = statuses.map do |status|
|
||||||
expected = 1.0
|
expected = 1.0
|
||||||
observed = (status.reblogs_count + status.favourites_count + status.emoji_reactions_count * 0.3).to_f
|
observed = (status.reblogs_count + status.favourites_count + status.emoji_reactions_count_per_account * 0.8).to_f
|
||||||
|
|
||||||
score = if expected > observed || observed < options[:threshold]
|
score = if expected > observed || observed < options[:threshold]
|
||||||
0
|
0
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :agreement, as: :boolean, wrapper: :with_label, label: t('auth.privacy_policy_agreement_html', rules_path: about_more_path, privacy_policy_path: privacy_policy_path), required: true
|
= f.input :agreement, as: :boolean, wrapper: :with_label, label: t('auth.privacy_policy_agreement_html', rules_path: about_more_path, privacy_policy_path: privacy_policy_path), required: true
|
||||||
|
|
||||||
|
%div
|
||||||
|
= t('auth.cloudflare_with_registering')
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
= f.button :button, @invite.present? ? t('auth.register') : sign_up_message, type: :submit
|
= f.button :button, @invite.present? ? t('auth.register') : sign_up_message, type: :submit
|
||||||
|
|
||||||
|
|
|
@ -994,6 +994,7 @@ en:
|
||||||
auth:
|
auth:
|
||||||
apply_for_account: Request an account
|
apply_for_account: Request an account
|
||||||
change_password: Password
|
change_password: Password
|
||||||
|
cloudflare_with_registering: With cloudflare on auth
|
||||||
confirmations:
|
confirmations:
|
||||||
wrong_email_hint: If that e-mail address is not correct, you can change it in account settings.
|
wrong_email_hint: If that e-mail address is not correct, you can change it in account settings.
|
||||||
delete_account: Delete account
|
delete_account: Delete account
|
||||||
|
@ -1422,6 +1423,7 @@ en:
|
||||||
title: Privacy Policy
|
title: Privacy Policy
|
||||||
reactions:
|
reactions:
|
||||||
errors:
|
errors:
|
||||||
|
duplication: Cannot react same things
|
||||||
limit_reached: Limit of different reactions reached
|
limit_reached: Limit of different reactions reached
|
||||||
unrecognized_emoji: is not a recognized emoji
|
unrecognized_emoji: is not a recognized emoji
|
||||||
relationships:
|
relationships:
|
||||||
|
|
|
@ -976,6 +976,7 @@ ja:
|
||||||
auth:
|
auth:
|
||||||
apply_for_account: アカウントのリクエスト
|
apply_for_account: アカウントのリクエスト
|
||||||
change_password: パスワード
|
change_password: パスワード
|
||||||
|
cloudflare_with_registering: 登録時にCloudflareの画面が表示されます。登録できないときは tt@kmycode.net までご連絡ください
|
||||||
confirmations:
|
confirmations:
|
||||||
wrong_email_hint: メールアドレスが正しくない場合は、アカウント設定で変更できます。
|
wrong_email_hint: メールアドレスが正しくない場合は、アカウント設定で変更できます。
|
||||||
delete_account: アカウントの削除
|
delete_account: アカウントの削除
|
||||||
|
@ -1395,6 +1396,7 @@ ja:
|
||||||
title: プライバシーポリシー
|
title: プライバシーポリシー
|
||||||
reactions:
|
reactions:
|
||||||
errors:
|
errors:
|
||||||
|
duplication: 同じリアクションを複数行おうとしました
|
||||||
limit_reached: リアクションの種類が上限に達しました
|
limit_reached: リアクションの種類が上限に達しました
|
||||||
unrecognized_emoji: は絵文字として認識されていません
|
unrecognized_emoji: は絵文字として認識されていません
|
||||||
relationships:
|
relationships:
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddEmojiReactionsCountPerAccountToStatusStats < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :status_stats, :emoji_reactions_count_per_account, :integer, null: false, default: 0
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2023_04_12_073021) do
|
ActiveRecord::Schema.define(version: 2023_04_14_010523) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -936,6 +936,7 @@ ActiveRecord::Schema.define(version: 2023_04_12_073021) do
|
||||||
t.string "emoji_reactions"
|
t.string "emoji_reactions"
|
||||||
t.integer "emoji_reactions_count", default: 0, null: false
|
t.integer "emoji_reactions_count", default: 0, null: false
|
||||||
t.integer "test", default: 0, null: false
|
t.integer "test", default: 0, null: false
|
||||||
|
t.integer "emoji_reactions_count_per_account", default: 0, null: false
|
||||||
t.index ["status_id"], name: "index_status_stats_on_status_id", unique: true
|
t.index ["status_id"], name: "index_status_stats_on_status_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue