Class: Seo::VisitsSyncService
- Inherits:
-
BaseService
- Object
- BaseService
- Seo::VisitsSyncService
- Defined in:
- app/services/seo/visits_sync_service.rb
Overview
Syncs first-party page view counts from the Visits table.
Writes to site_map_data_points (source of truth) and updates visit_count_30d on site_maps (cached for SQL sorting).
This provides 100% accurate first-party data on actual page views,
independent of third-party analytics services.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ VisitsSyncService
constructor
A new instance of VisitsSyncService.
- #process ⇒ Object
Methods inherited from BaseService
#log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
#initialize(options = {}) ⇒ VisitsSyncService
Returns a new instance of VisitsSyncService.
17 18 19 20 21 |
# File 'app/services/seo/visits_sync_service.rb', line 17 def initialize( = {}) super @site_map_ids = [:site_map_ids] @stats = { pages_updated: 0, errors: [] } end |
Instance Method Details
#process ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/seo/visits_sync_service.rb', line 23 def process @logger.info '[VisitsSyncService] Starting visit count sync' site_maps = @site_map_ids.present? ? SiteMap.where(id: @site_map_ids) : SiteMap.all site_maps.find_each do |site_map| sync_visit_counts(site_map) end @logger.info "[VisitsSyncService] Completed: #{@stats[:pages_updated]} pages updated" @stats end |