Merge remote-tracking branch 'parent/main' into upstream-20240109
This commit is contained in:
commit
d35fa72842
333 changed files with 4444 additions and 2541 deletions
|
@ -13,7 +13,7 @@ class ActivityPub::TagManager
|
|||
}.freeze
|
||||
|
||||
def public_collection?(uri)
|
||||
uri == COLLECTIONS[:public] || uri == 'as:Public' || uri == 'Public'
|
||||
uri == COLLECTIONS[:public] || %w(as:Public Public).include?(uri)
|
||||
end
|
||||
|
||||
def url_for(target)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source
|
||||
MINIMUM_INTERACTIONS = 1
|
||||
SET_SIZE = 40
|
||||
|
||||
def generate
|
||||
|
@ -17,6 +18,10 @@ class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source
|
|||
private
|
||||
|
||||
def commonly_interacted_with_accounts
|
||||
report_statuses.where.not(in_reply_to_account_id: @account.id).group(:in_reply_to_account_id).having('count(*) > 1').order(count_all: :desc).limit(SET_SIZE).count
|
||||
report_statuses.where.not(in_reply_to_account_id: @account.id).group(:in_reply_to_account_id).having(minimum_interaction_count).order(count_all: :desc).limit(SET_SIZE).count
|
||||
end
|
||||
|
||||
def minimum_interaction_count
|
||||
Arel.star.count.gt(MINIMUM_INTERACTIONS)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AnnualReport::MostRebloggedAccounts < AnnualReport::Source
|
||||
MINIMUM_REBLOGS = 1
|
||||
SET_SIZE = 10
|
||||
|
||||
def generate
|
||||
|
@ -17,6 +18,10 @@ class AnnualReport::MostRebloggedAccounts < AnnualReport::Source
|
|||
private
|
||||
|
||||
def most_reblogged_accounts
|
||||
report_statuses.where.not(reblog_of_id: nil).joins(reblog: :account).group(accounts: [:id]).having('count(*) > 1').order(count_all: :desc).limit(SET_SIZE).count
|
||||
report_statuses.where.not(reblog_of_id: nil).joins(reblog: :account).group(accounts: [:id]).having(minimum_reblog_count).order(count_all: :desc).limit(SET_SIZE).count
|
||||
end
|
||||
|
||||
def minimum_reblog_count
|
||||
Arel.star.count.gt(MINIMUM_REBLOGS)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AnnualReport::TopHashtags < AnnualReport::Source
|
||||
MINIMUM_TAGGINGS = 1
|
||||
SET_SIZE = 40
|
||||
|
||||
def generate
|
||||
|
@ -17,7 +18,11 @@ class AnnualReport::TopHashtags < AnnualReport::Source
|
|||
private
|
||||
|
||||
def top_hashtags
|
||||
Tag.joins(:statuses).where(statuses: { id: report_statuses.select(:id) }).group(coalesced_tag_names).having('count(*) > 1').order(count_all: :desc).limit(SET_SIZE).count
|
||||
Tag.joins(:statuses).where(statuses: { id: report_statuses.select(:id) }).group(coalesced_tag_names).having(minimum_taggings_count).order(count_all: :desc).limit(SET_SIZE).count
|
||||
end
|
||||
|
||||
def minimum_taggings_count
|
||||
Arel.star.count.gt(MINIMUM_TAGGINGS)
|
||||
end
|
||||
|
||||
def coalesced_tag_names
|
||||
|
|
|
@ -3,14 +3,18 @@
|
|||
module ApplicationExtension
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
APP_NAME_LIMIT = 60
|
||||
APP_REDIRECT_URI_LIMIT = 2_000
|
||||
APP_WEBSITE_LIMIT = 2_000
|
||||
|
||||
included do
|
||||
include Redisable
|
||||
|
||||
has_many :created_users, class_name: 'User', foreign_key: 'created_by_application_id', inverse_of: :created_by_application
|
||||
|
||||
validates :name, length: { maximum: 60 }
|
||||
validates :website, url: true, length: { maximum: 2_000 }, if: :website?
|
||||
validates :redirect_uri, length: { maximum: 2_000 }
|
||||
validates :name, length: { maximum: APP_NAME_LIMIT }
|
||||
validates :redirect_uri, length: { maximum: APP_REDIRECT_URI_LIMIT }
|
||||
validates :website, url: true, length: { maximum: APP_WEBSITE_LIMIT }, if: :website?
|
||||
|
||||
# The relationship used between Applications and AccessTokens is using
|
||||
# dependent: delete_all, which means the ActiveRecord callback in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue