Class: Sentiero::Analytics::StatsAggregator::ResultBuilder
- Inherits:
-
Object
- Object
- Sentiero::Analytics::StatsAggregator::ResultBuilder
- Includes:
- Events, Sentiero::Analytics::Stats
- Defined in:
- lib/sentiero/analytics/stats_aggregator/result_builder.rb
Overview
Pure presentation layer: turns a finished Accumulator into the aggregate's public result hash. Needs the store only for the two problem lookups (open_problems count and the top_problems list).
Constant Summary
Constants included from Events
Events::CUSTOM, Events::INCREMENTAL, Events::META, Events::SOURCE_INPUT, Events::SOURCE_MOUSE_INTERACTION, Events::SOURCE_SCROLL
Instance Method Summary collapse
- #build(acc, sessions_scanned, scan_cap, server_overlay_truncated) ⇒ Object
-
#initialize(store) ⇒ ResultBuilder
constructor
A new instance of ResultBuilder.
Methods included from Sentiero::Analytics::Stats
#mean, #offset_ms, #percentile, #top_counts
Constructor Details
#initialize(store) ⇒ ResultBuilder
Returns a new instance of ResultBuilder.
13 14 15 |
# File 'lib/sentiero/analytics/stats_aggregator/result_builder.rb', line 13 def initialize(store) @store = store end |
Instance Method Details
#build(acc, sessions_scanned, scan_cap, server_overlay_truncated) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sentiero/analytics/stats_aggregator/result_builder.rb', line 17 def build(acc, sessions_scanned, scan_cap, ) open_problems = store.list_problems(project: nil, limit: 10_000, status: "open") groups, series_bucket = bucket_groups(acc) series = groups.map { |label, dates| series_entry(acc, label, dates) } = (acc..) { total_sessions: sessions_scanned, total_events: acc.total_events, sessions_scanned: sessions_scanned, avg_duration_ms: average(acc.durations), open_problems: open_problems.size, top_problems: top_problems(open_problems, acc.since), sessions_with_errors: acc.sessions_with_errors, event_type_breakdown: event_type_breakdown(acc.event_types), browser_distribution: sort_by_count(acc.browsers), device_distribution: sort_by_count(acc.devices), top_entry_pages: top_entry_pages(acc), top_referrers: top_list(acc.referrers, :referrer, StatsAggregator::TOP_LIST_LIMIT), session_duration_buckets: acc.duration_buckets, custom_event_tags: , custom_event_tag_series: tag_series(acc, , groups), browser_event_tags: acc., navigation: { internal: top_list(acc.nav_internal, :url, StatsAggregator::TOP_LIST_LIMIT), external: top_list(acc.nav_external, :url, StatsAggregator::TOP_LIST_LIMIT), top_texts: top_list(acc.nav_texts, :text, StatsAggregator::TOP_LIST_LIMIT) }, metadata_distributions: (acc), events_per_day_series: series, series_bucket: series_bucket, # True when a cap was hit: server_error_count values are then a lower bound. server_overlay_truncated: , # Effective bounds (unbounded "until" resolves to now) for period-over-period. window_since: acc.since, window_until: acc.until_time || Time.now.to_f, was_truncated: sessions_scanned >= scan_cap } end |