A platform for community discussion. Free, open, simple.
FEATURE: Add WebHookEventsDailyAggregate report page (#27573)
Gabriel Grubba8d280386668d
diff --git a/app/assets/javascripts/admin/addon/components/report-filters/group.hbs b/app/assets/javascripts/admin/addon/components/report-filters/group.hbsindex f9dbdb32fd3..b41478c8f53 100644--- a/app/assets/javascripts/admin/addon/components/report-filters/group.hbs+++ b/app/assets/javascripts/admin/addon/components/report-filters/group.hbs@@ -5,6 +5,7 @@@onChange={{this.onChange}}@options={{hashallowAny=this.filter.allow_any+ autoInsertNoneItem=this.filter.auto_insert_none_itemfilterable=truenone="admin.dashboard.reports.groups"}}diff --git a/app/assets/javascripts/admin/addon/components/report-filters/list.hbs b/app/assets/javascripts/admin/addon/components/report-filters/list.hbsindex c642a0ec7ae..c41f8c3ba46 100644--- a/app/assets/javascripts/admin/addon/components/report-filters/list.hbs+++ b/app/assets/javascripts/admin/addon/components/report-filters/list.hbs@@ -4,6 +4,7 @@@onChange={{this.onChange}}@options={{hashallowAny=this.filter.allow_any+ autoInsertNoneItem=this.filter.auto_insert_none_itemfilterable=truenone="admin.dashboard.report_filter_any"}}diff --git a/app/models/concerns/reports/web_hook_events_daily_aggregate.rb b/app/models/concerns/reports/web_hook_events_daily_aggregate.rbnew file mode 100644index 00000000000..f701c2f214b--- /dev/null+++ b/app/models/concerns/reports/web_hook_events_daily_aggregate.rb@@ -0,0 +1,63 @@+# frozen_string_literal: true++module Reports::WebHookEventsDailyAggregate+ extend ActiveSupport::Concern+ class_methods do+ def report_web_hook_events_daily_aggregate(report)+ report.labels = [+ { type: :date, property: :x, title: I18n.t("reports.default.labels.day") },+ { type: :percent, property: :y, title: I18n.t("reports.default.labels.percent") },+ ]++ type = report.filters.dig(:type_of_web_hook_event)+ # all = failed_events + successful_events per day;+ # failed events = failed events per day;+ # successful events = successful events per day;+ # mean duration = mean duration of all events per day;+ report.add_filter(+ "type_of_web_hook_event",+ type: "list",+ default: type || "all",+ choices:+ ["all", "failed events", "successful events", "mean duration"].map do |t|+ { id: t, name: t }+ end,+ allow_any: false,+ auto_insert_none_item: false,+ )++ report.average = true+ report.percent = true++ data_points = WebHookEventsDailyAggregate.by_day(report.start_date, report.end_date)++ report.data = []++ data_points.each do |data_point|+ case type+ when "failed events"+ report.data << { x: data_point["date"], y: data_point["failed_event_count"] }+ when "successful events"+ report.data << { x: data_point["date"], y: data_point["successful_event_count"] }+ when "mean duration"+ report.data << { x: data_point["date"], y: data_point["mean_duration"] }+ else+ report.data << {+ x: data_point["date"],+ y: data_point["successful_event_count"] + data_point["failed_event_count"],+ }+ end+ end++ if report.facets.include?(:prev_period)+ report.prev_period =+ WebHookEventsDailyAggregate.by_day(report.prev_start_date, report.prev_end_date)+ end++ if report.facets.include?(:prev30Days)+ report.prev30Days =+ WebHookEventsDailyAggregate.by_day(report.start_date - 30.days, report.start_date)+ end+ end+ end+enddiff --git a/app/models/report.rb b/app/models/report.rbindex 68b91237e79..e1141fda5bd 100644--- a/app/models/report.rb+++ b/app/models/report.rb@@ -16,50 +16,51 @@ class Reportinclude_subcategories]- include Reports::PostEdits- include Reports::TopTrafficSources- include Reports::TopicsWithNoResponse+ include Reports::Bookmarks+ include Reports::ConsolidatedApiRequests+ include Reports::ConsolidatedPageViews+ include Reports::ConsolidatedPageViewsBrowserDetection+ include Reports::DailyEngagedUsersinclude Reports::DauByMau- include Reports::FlagsStatusinclude Reports::Emails+ include Reports::Flags+ include Reports::FlagsStatusinclude Reports::Likes- include Reports::SystemPrivateMessages- include Reports::UsersByType- include Reports::StorageStats+ include Reports::MobileVisits+ include Reports::ModeratorWarningPrivateMessages+ include Reports::ModeratorsActivity+ include Reports::NewContributorsinclude Reports::NotifyModeratorsPrivateMessages- include Reports::SuspiciousLogins- include Reports::TopReferredTopics- include Reports::Signupsinclude Reports::NotifyUserPrivateMessages- include Reports::NewContributors- include Reports::TrendingSearch- include Reports::UserToUserPrivateMessages- include Reports::Flags- include Reports::Topics+ include Reports::PostEditsinclude Reports::Posts- include Reports::Bookmarks+ include Reports::ProfileViews+ include Reports::Signupsinclude Reports::StaffLogins- include Reports::DailyEngagedUsers- include Reports::UserToUserPrivateMessagesWithReplies- include Reports::MobileVisits- include Reports::TopReferrers- include Reports::WebCrawlers- include Reports::ModeratorsActivity- include Reports::TopIgnoredUsers- include Reports::UserFlaggingRatio- include Reports::TrustLevelGrowth- include Reports::ConsolidatedPageViews- include Reports::ConsolidatedPageViewsBrowserDetection- include Reports::ConsolidatedApiRequests- include Reports::Visits+ include Reports::StorageStats+ include Reports::SuspiciousLogins+ include Reports::SystemPrivateMessagesinclude Reports::TimeToFirstResponse- include Reports::UsersByTrustLevel- include Reports::ModeratorWarningPrivateMessages- include Reports::ProfileViews+ include Reports::TopIgnoredUsers+ include Reports::TopReferredTopics+ include Reports::TopReferrers+ include Reports::TopTrafficSourcesinclude Reports::TopUploadsinclude Reports::TopUsersByLikesReceived- include Reports::TopUsersByLikesReceivedFromInferiorTrustLevelinclude Reports::TopUsersByLikesReceivedFromAVarietyOfPeople+ include Reports::TopUsersByLikesReceivedFromInferiorTrustLevel+ include Reports::Topics+ include Reports::TopicsWithNoResponse+ include Reports::TrendingSearch+ include Reports::TrustLevelGrowth+ include Reports::UserFlaggingRatio+ include Reports::UserToUserPrivateMessages+ include Reports::UserToUserPrivateMessagesWithReplies+ include Reports::UsersByTrustLevel+ include Reports::UsersByType+ include Reports::Visits+ include Reports::WebCrawlers+ include Reports::WebHookEventsDailyAggregateattr_accessor :type,:data,diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex e076422e973..cbd639c204d 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -5038,6 +5038,8 @@ en:label: Categoryinclude_subcategories:label: "Include Subcategories"+ type_of_web_hook_event:+ label: "Type of event"flags:title: "Moderation Flags"description: "Description"diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex bb336533d62..1352735a18c 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -1570,6 +1570,11 @@ en:user_agent: "User Agent"page_views: "Pageviews"description: "List of web crawler user agents, sorted by pageviews."+ web_hook_events_daily_aggregate:+ title: "Web Hook Events"+ xaxis: "Day"+ yaxis: "Number of events"+ description: "Number of web hook events triggered or their mean duration."suspicious_logins:title: "Suspicious Logins"labels: