Add more instance stats APIs (#6125)
* Add GET /api/v1/instance/peers API to reveal known domains * Add GET /api/v1/instance/activity API * Make new APIs disableable, exclude private statuses from activity stats * Fix code style issue * Fix week timestamps
This commit is contained in:
parent
511c6f9625
commit
38fc1b498d
14 changed files with 144 additions and 8 deletions
|
@ -30,6 +30,10 @@ class Form::AdminSettings
|
|||
:bootstrap_timeline_accounts=,
|
||||
:min_invite_role,
|
||||
:min_invite_role=,
|
||||
:activity_api_enabled,
|
||||
:activity_api_enabled=,
|
||||
:peers_api_enabled,
|
||||
:peers_api_enabled=,
|
||||
to: Setting
|
||||
)
|
||||
end
|
||||
|
|
|
@ -135,6 +135,7 @@ class Status < ApplicationRecord
|
|||
end
|
||||
|
||||
after_create_commit :store_uri, if: :local?
|
||||
after_create_commit :update_statistics, if: :local?
|
||||
|
||||
around_create Mastodon::Snowflake::Callbacks
|
||||
|
||||
|
@ -308,4 +309,9 @@ class Status < ApplicationRecord
|
|||
def set_local
|
||||
self.local = account.local?
|
||||
end
|
||||
|
||||
def update_statistics
|
||||
return unless public_visibility? || unlisted_visibility?
|
||||
ActivityTracker.increment('activity:statuses:local')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -122,9 +122,19 @@ class User < ApplicationRecord
|
|||
update!(disabled: false)
|
||||
end
|
||||
|
||||
def confirm
|
||||
return if confirmed?
|
||||
|
||||
super
|
||||
update_statistics!
|
||||
end
|
||||
|
||||
def confirm!
|
||||
return if confirmed?
|
||||
|
||||
skip_confirmation!
|
||||
save!
|
||||
update_statistics!
|
||||
end
|
||||
|
||||
def promote!
|
||||
|
@ -202,4 +212,9 @@ class User < ApplicationRecord
|
|||
def sanitize_languages
|
||||
filtered_languages.reject!(&:blank?)
|
||||
end
|
||||
|
||||
def update_statistics!
|
||||
BootstrapTimelineWorker.perform_async(account_id)
|
||||
ActivityTracker.increment('activity:accounts:local')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue