mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Compare commits
20 commits
e0eae6f104
...
8c5dc87452
Author | SHA1 | Date | |
---|---|---|---|
|
8c5dc87452 | ||
|
a50c8e951f | ||
|
2c1e75727d | ||
|
677a17dcef | ||
|
960acfca72 | ||
|
b22a152d9d | ||
|
84411d4c97 | ||
|
f87bbe6184 | ||
|
f3d9e61639 | ||
|
abe946296b | ||
|
324e9673cb | ||
|
e0692262d1 | ||
|
4273e780c7 | ||
|
f019cbdadb | ||
|
32849942a1 | ||
|
87796e6680 | ||
|
f1e35a60e6 | ||
|
c570eca393 | ||
|
13888d827c | ||
|
e2a243ae31 |
16 changed files with 115 additions and 235 deletions
|
@ -60,7 +60,7 @@ export interface BaseNotificationGroupJSON {
|
||||||
|
|
||||||
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
|
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
|
||||||
type: NotificationWithStatusType;
|
type: NotificationWithStatusType;
|
||||||
status: ApiStatusJSON;
|
status_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NotificationWithStatusJSON extends BaseNotificationJSON {
|
interface NotificationWithStatusJSON extends BaseNotificationJSON {
|
||||||
|
|
|
@ -49,22 +49,15 @@ export const FilteredNotificationsBanner: React.FC = () => {
|
||||||
<span>
|
<span>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='filtered_notifications_banner.pending_requests'
|
id='filtered_notifications_banner.pending_requests'
|
||||||
defaultMessage='Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
defaultMessage='From {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
||||||
values={{ count: policy.summary.pending_requests_count }}
|
values={{ count: policy.summary.pending_requests_count }}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='filtered-notifications-banner__badge'>
|
<div className='filtered-notifications-banner__badge'>
|
||||||
<div className='filtered-notifications-banner__badge__badge'>
|
|
||||||
{toCappedNumber(policy.summary.pending_notifications_count)}
|
{toCappedNumber(policy.summary.pending_notifications_count)}
|
||||||
</div>
|
</div>
|
||||||
<FormattedMessage
|
|
||||||
id='filtered_notifications_banner.mentions'
|
|
||||||
defaultMessage='{count, plural, one {mention} other {mentions}}'
|
|
||||||
values={{ count: policy.summary.pending_notifications_count }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -300,8 +300,7 @@
|
||||||
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
|
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
|
||||||
"filter_modal.select_filter.title": "Filter this post",
|
"filter_modal.select_filter.title": "Filter this post",
|
||||||
"filter_modal.title.status": "Filter a post",
|
"filter_modal.title.status": "Filter a post",
|
||||||
"filtered_notifications_banner.mentions": "{count, plural, one {mention} other {mentions}}",
|
"filtered_notifications_banner.pending_requests": "From {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
||||||
"filtered_notifications_banner.pending_requests": "Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
|
||||||
"filtered_notifications_banner.title": "Filtered notifications",
|
"filtered_notifications_banner.title": "Filtered notifications",
|
||||||
"firehose.all": "All",
|
"firehose.all": "All",
|
||||||
"firehose.local": "This server",
|
"firehose.local": "This server",
|
||||||
|
|
|
@ -124,9 +124,9 @@ export function createNotificationGroupFromJSON(
|
||||||
case 'mention':
|
case 'mention':
|
||||||
case 'poll':
|
case 'poll':
|
||||||
case 'update': {
|
case 'update': {
|
||||||
const { status, ...groupWithoutStatus } = group;
|
const { status_id: statusId, ...groupWithoutStatus } = group;
|
||||||
return {
|
return {
|
||||||
statusId: status.id,
|
statusId,
|
||||||
sampleAccountIds,
|
sampleAccountIds,
|
||||||
...groupWithoutStatus,
|
...groupWithoutStatus,
|
||||||
};
|
};
|
||||||
|
|
|
@ -10170,27 +10170,12 @@ noscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__badge {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: var(--background-border-color);
|
|
||||||
color: $darker-text-color;
|
|
||||||
padding: 4px;
|
|
||||||
padding-inline-end: 8px;
|
|
||||||
gap: 6px;
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 11px;
|
|
||||||
line-height: 16px;
|
|
||||||
word-break: keep-all;
|
|
||||||
|
|
||||||
&__badge {
|
&__badge {
|
||||||
background: $ui-button-background-color;
|
background: $ui-button-background-color;
|
||||||
color: $white;
|
color: $white;
|
||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
padding: 2px 8px;
|
padding: 2px 8px;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification-request {
|
.notification-request {
|
||||||
|
|
|
@ -27,25 +27,11 @@ class Admin::Metrics::Measure::InstanceAccountsMeasure < Admin::Metrics::Measure
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
|
Account
|
||||||
end
|
.select(:id)
|
||||||
|
.where(account_domain_sql, domain: params[:domain])
|
||||||
def sql_query_string
|
.where(daily_period(:accounts))
|
||||||
<<~SQL.squish
|
|
||||||
SELECT axis.*, (
|
|
||||||
WITH new_accounts AS (
|
|
||||||
SELECT accounts.id
|
|
||||||
FROM accounts
|
|
||||||
WHERE date_trunc('day', accounts.created_at)::date = axis.period
|
|
||||||
AND #{account_domain_sql(params[:include_subdomains])}
|
|
||||||
)
|
|
||||||
SELECT count(*) FROM new_accounts
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) AS axis
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
|
|
|
@ -27,26 +27,12 @@ class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measur
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
|
Follow
|
||||||
end
|
.select(:id)
|
||||||
|
.joins(:account)
|
||||||
def sql_query_string
|
.where(account_domain_sql, domain: params[:domain])
|
||||||
<<~SQL.squish
|
.where(daily_period(:follows))
|
||||||
SELECT axis.*, (
|
|
||||||
WITH new_followers AS (
|
|
||||||
SELECT follows.id
|
|
||||||
FROM follows
|
|
||||||
INNER JOIN accounts ON follows.account_id = accounts.id
|
|
||||||
WHERE date_trunc('day', follows.created_at)::date = axis.period
|
|
||||||
AND #{account_domain_sql(params[:include_subdomains])}
|
|
||||||
)
|
|
||||||
SELECT count(*) FROM new_followers
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) AS axis
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
|
|
|
@ -27,26 +27,12 @@ class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure:
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
|
Follow
|
||||||
end
|
.select(:id)
|
||||||
|
.joins(:target_account)
|
||||||
def sql_query_string
|
.where(account_domain_sql, domain: params[:domain])
|
||||||
<<~SQL.squish
|
.where(daily_period(:follows))
|
||||||
SELECT axis.*, (
|
|
||||||
WITH new_follows AS (
|
|
||||||
SELECT follows.id
|
|
||||||
FROM follows
|
|
||||||
INNER JOIN accounts ON follows.target_account_id = accounts.id
|
|
||||||
WHERE date_trunc('day', follows.created_at)::date = axis.period
|
|
||||||
AND #{account_domain_sql(params[:include_subdomains])}
|
|
||||||
)
|
|
||||||
SELECT count(*) FROM new_follows
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) AS axis
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
|
|
|
@ -36,25 +36,23 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics:
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
|
MediaAttachment
|
||||||
|
.select(media_size_total)
|
||||||
|
.joins(:account)
|
||||||
|
.where(account_domain_sql, domain: params[:domain])
|
||||||
|
.where(daily_period(:media_attachments))
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_query_string
|
def select_target
|
||||||
<<~SQL.squish
|
<<~SQL.squish
|
||||||
SELECT axis.*, (
|
COALESCE(SUM(size), 0)
|
||||||
WITH new_media_attachments AS (
|
SQL
|
||||||
SELECT COALESCE(media_attachments.file_file_size, 0) + COALESCE(media_attachments.thumbnail_file_size, 0) AS size
|
end
|
||||||
FROM media_attachments
|
|
||||||
INNER JOIN accounts ON accounts.id = media_attachments.account_id
|
def media_size_total
|
||||||
WHERE date_trunc('day', media_attachments.created_at)::date = axis.period
|
<<~SQL.squish
|
||||||
AND #{account_domain_sql(params[:include_subdomains])}
|
COALESCE(media_attachments.file_file_size, 0) + COALESCE(media_attachments.thumbnail_file_size, 0) AS size
|
||||||
)
|
|
||||||
SELECT COALESCE(SUM(size), 0) FROM new_media_attachments
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) AS axis
|
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,26 +27,12 @@ class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure:
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain] }]
|
Report
|
||||||
end
|
.select(:id)
|
||||||
|
.joins(:target_account)
|
||||||
def sql_query_string
|
.where(account_domain_sql, domain: params[:domain])
|
||||||
<<~SQL.squish
|
.where(daily_period(:reports))
|
||||||
SELECT axis.*, (
|
|
||||||
WITH new_reports AS (
|
|
||||||
SELECT reports.id
|
|
||||||
FROM reports
|
|
||||||
INNER JOIN accounts ON accounts.id = reports.target_account_id
|
|
||||||
WHERE date_trunc('day', reports.created_at)::date = axis.period
|
|
||||||
AND #{account_domain_sql(params[:include_subdomains])}
|
|
||||||
)
|
|
||||||
SELECT count(*) FROM new_reports
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) AS axis
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
|
|
|
@ -27,27 +27,13 @@ class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at, domain: params[:domain], earliest_status_id: earliest_status_id, latest_status_id: latest_status_id }]
|
Status
|
||||||
end
|
.select(:id)
|
||||||
|
.joins(:account)
|
||||||
def sql_query_string
|
.where(account_domain_sql, domain: params[:domain])
|
||||||
<<~SQL.squish
|
.where(status_range_sql, earliest_status_id: earliest_status_id, latest_status_id: latest_status_id)
|
||||||
SELECT axis.*, (
|
.where(daily_period(:statuses))
|
||||||
WITH new_statuses AS (
|
|
||||||
SELECT statuses.id
|
|
||||||
FROM statuses
|
|
||||||
INNER JOIN accounts ON accounts.id = statuses.account_id
|
|
||||||
WHERE statuses.id BETWEEN :earliest_status_id AND :latest_status_id
|
|
||||||
AND #{account_domain_sql(params[:include_subdomains])}
|
|
||||||
AND date_trunc('day', statuses.created_at)::date = axis.period
|
|
||||||
)
|
|
||||||
SELECT count(*) FROM new_statuses
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) AS axis
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def earliest_status_id
|
def earliest_status_id
|
||||||
|
|
|
@ -17,23 +17,9 @@ class Admin::Metrics::Measure::NewUsersMeasure < Admin::Metrics::Measure::BaseMe
|
||||||
User.where(created_at: previous_time_period).count
|
User.where(created_at: previous_time_period).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at }]
|
User
|
||||||
end
|
.select(:id)
|
||||||
|
.where(daily_period(:users))
|
||||||
def sql_query_string
|
|
||||||
<<~SQL.squish
|
|
||||||
SELECT axis.*, (
|
|
||||||
WITH new_users AS (
|
|
||||||
SELECT users.id
|
|
||||||
FROM users
|
|
||||||
WHERE date_trunc('day', users.created_at)::date = axis.period
|
|
||||||
)
|
|
||||||
SELECT count(*) FROM new_users
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) AS axis
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,23 +17,9 @@ class Admin::Metrics::Measure::OpenedReportsMeasure < Admin::Metrics::Measure::B
|
||||||
Report.where(created_at: previous_time_period).count
|
Report.where(created_at: previous_time_period).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at }]
|
Report
|
||||||
end
|
.select(:id)
|
||||||
|
.where(daily_period(:reports))
|
||||||
def sql_query_string
|
|
||||||
<<~SQL.squish
|
|
||||||
SELECT axis.*, (
|
|
||||||
WITH new_reports AS (
|
|
||||||
SELECT reports.id
|
|
||||||
FROM reports
|
|
||||||
WHERE date_trunc('day', reports.created_at)::date = axis.period
|
|
||||||
)
|
|
||||||
SELECT count(*) FROM new_reports
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) AS axis
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,19 +15,49 @@ module Admin::Metrics::Measure::QueryHelper
|
||||||
ActiveRecord::Base.sanitize_sql_array(sql_array)
|
ActiveRecord::Base.sanitize_sql_array(sql_array)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generated_series_days
|
def sql_array
|
||||||
Arel.sql(
|
[sql_query_string, { start_at: @start_at, end_at: @end_at }]
|
||||||
<<~SQL.squish
|
|
||||||
SELECT generate_series(:start_at::timestamp, :end_at::timestamp, '1 day')::date AS period
|
|
||||||
SQL
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_domain_sql(include_subdomains)
|
def sql_query_string
|
||||||
if include_subdomains
|
<<~SQL.squish
|
||||||
"accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || :domain::text))"
|
SELECT axis.*, (
|
||||||
|
WITH data_source AS (#{data_source.to_sql})
|
||||||
|
SELECT #{select_target} FROM data_source
|
||||||
|
) AS value
|
||||||
|
FROM (
|
||||||
|
SELECT generate_series(:start_at::timestamp, :end_at::timestamp, '1 day')::date AS period
|
||||||
|
) AS axis
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
def select_target
|
||||||
|
<<~SQL.squish
|
||||||
|
COUNT(*)
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
def daily_period(table, column = :created_at)
|
||||||
|
<<~SQL.squish
|
||||||
|
DATE_TRUNC('day', #{table}.#{column})::date = axis.period
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
def status_range_sql
|
||||||
|
<<~SQL.squish
|
||||||
|
statuses.id BETWEEN :earliest_status_id AND :latest_status_id
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
def account_domain_sql
|
||||||
|
if params[:include_subdomains]
|
||||||
|
<<~SQL.squish
|
||||||
|
accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || :domain::text))
|
||||||
|
SQL
|
||||||
else
|
else
|
||||||
'accounts.domain = :domain::text'
|
<<~SQL.squish
|
||||||
|
accounts.domain = :domain::text
|
||||||
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,23 +17,9 @@ class Admin::Metrics::Measure::ResolvedReportsMeasure < Admin::Metrics::Measure:
|
||||||
Report.resolved.where(action_taken_at: previous_time_period).count
|
Report.resolved.where(action_taken_at: previous_time_period).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at }]
|
Report
|
||||||
end
|
.select(:id)
|
||||||
|
.where(daily_period(:reports, :action_taken_at))
|
||||||
def sql_query_string
|
|
||||||
<<~SQL.squish
|
|
||||||
SELECT axis.*, (
|
|
||||||
WITH resolved_reports AS (
|
|
||||||
SELECT reports.id
|
|
||||||
FROM reports
|
|
||||||
WHERE date_trunc('day', reports.action_taken_at)::date = axis.period
|
|
||||||
)
|
|
||||||
SELECT count(*) FROM resolved_reports
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) AS axis
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,28 +21,15 @@ class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::Base
|
||||||
tag.statuses.where('statuses.id BETWEEN ? AND ?', Mastodon::Snowflake.id_at(@start_at - length_of_period, with_random: false), Mastodon::Snowflake.id_at(@end_at - length_of_period, with_random: false)).joins(:account).count('distinct accounts.domain')
|
tag.statuses.where('statuses.id BETWEEN ? AND ?', Mastodon::Snowflake.id_at(@start_at - length_of_period, with_random: false), Mastodon::Snowflake.id_at(@end_at - length_of_period, with_random: false)).joins(:account).count('distinct accounts.domain')
|
||||||
end
|
end
|
||||||
|
|
||||||
def sql_array
|
def data_source
|
||||||
[sql_query_string, { start_at: @start_at, end_at: @end_at, tag_id: tag.id, earliest_status_id: earliest_status_id, latest_status_id: latest_status_id }]
|
Status
|
||||||
end
|
.select('accounts.domain')
|
||||||
|
.distinct
|
||||||
def sql_query_string
|
.reorder(nil)
|
||||||
<<~SQL.squish
|
.joins(:tags, :account)
|
||||||
SELECT axis.*, (
|
.where(statuses_tags: { tag_id: tag.id })
|
||||||
WITH tag_servers AS (
|
.where(status_range_sql, earliest_status_id: earliest_status_id, latest_status_id: latest_status_id)
|
||||||
SELECT DISTINCT accounts.domain
|
.where(daily_period(:statuses))
|
||||||
FROM statuses
|
|
||||||
INNER JOIN statuses_tags ON statuses.id = statuses_tags.status_id
|
|
||||||
INNER JOIN accounts ON statuses.account_id = accounts.id
|
|
||||||
WHERE statuses_tags.tag_id = :tag_id
|
|
||||||
AND statuses.id BETWEEN :earliest_status_id AND :latest_status_id
|
|
||||||
AND date_trunc('day', statuses.created_at)::date = axis.period
|
|
||||||
)
|
|
||||||
SELECT COUNT(*) FROM tag_servers
|
|
||||||
) AS value
|
|
||||||
FROM (
|
|
||||||
#{generated_series_days}
|
|
||||||
) as axis
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def earliest_status_id
|
def earliest_status_id
|
||||||
|
|
Loading…
Reference in a new issue