1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-01 00:08:39 +09:00

Consolidate time periods methods into base measure (#30757)

This commit is contained in:
Matt Jankowski 2024-06-19 04:45:47 -04:00 committed by GitHub
parent 80743e0e7f
commit a8b3d2e4e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 2 additions and 82 deletions

View File

@ -22,12 +22,4 @@ class Admin::Metrics::Measure::ActiveUsersMeasure < Admin::Metrics::Measure::Bas
def activity_tracker def activity_tracker
@activity_tracker ||= ActivityTracker.new('activity:logins', :unique) @activity_tracker ||= ActivityTracker.new('activity:logins', :unique)
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
end end

View File

@ -86,11 +86,11 @@ class Admin::Metrics::Measure::BaseMeasure
end end
def time_period def time_period
(@start_at..@end_at) (@start_at.to_date..@end_at.to_date)
end end
def previous_time_period def previous_time_period
((@start_at - length_of_period)..(@end_at - length_of_period)) ((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end end
def length_of_period def length_of_period

View File

@ -48,14 +48,6 @@ class Admin::Metrics::Measure::InstanceAccountsMeasure < Admin::Metrics::Measure
SQL SQL
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
def params def params
@params.permit(:domain, :include_subdomains) @params.permit(:domain, :include_subdomains)
end end

View File

@ -49,14 +49,6 @@ class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measur
SQL SQL
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
def params def params
@params.permit(:domain, :include_subdomains) @params.permit(:domain, :include_subdomains)
end end

View File

@ -49,14 +49,6 @@ class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure:
SQL SQL
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
def params def params
@params.permit(:domain, :include_subdomains) @params.permit(:domain, :include_subdomains)
end end

View File

@ -58,14 +58,6 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics:
SQL SQL
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
def params def params
@params.permit(:domain, :include_subdomains) @params.permit(:domain, :include_subdomains)
end end

View File

@ -49,14 +49,6 @@ class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure:
SQL SQL
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
def params def params
@params.permit(:domain, :include_subdomains) @params.permit(:domain, :include_subdomains)
end end

View File

@ -58,14 +58,6 @@ class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure
Mastodon::Snowflake.id_at(@end_at.end_of_day, with_random: false) Mastodon::Snowflake.id_at(@end_at.end_of_day, with_random: false)
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
def params def params
@params.permit(:domain, :include_subdomains) @params.permit(:domain, :include_subdomains)
end end

View File

@ -22,12 +22,4 @@ class Admin::Metrics::Measure::InteractionsMeasure < Admin::Metrics::Measure::Ba
def activity_tracker def activity_tracker
@activity_tracker ||= ActivityTracker.new('activity:interactions', :basic) @activity_tracker ||= ActivityTracker.new('activity:interactions', :basic)
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
end end

View File

@ -27,14 +27,6 @@ class Admin::Metrics::Measure::TagAccountsMeasure < Admin::Metrics::Measure::Bas
@tag ||= Tag.find(params[:id]) @tag ||= Tag.find(params[:id])
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
def params def params
@params.permit(:id) @params.permit(:id)
end end

View File

@ -27,14 +27,6 @@ class Admin::Metrics::Measure::TagUsesMeasure < Admin::Metrics::Measure::BaseMea
@tag ||= Tag.find(params[:id]) @tag ||= Tag.find(params[:id])
end end
def time_period
(@start_at.to_date..@end_at.to_date)
end
def previous_time_period
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
end
def params def params
@params.permit(:id) @params.permit(:id)
end end