<?php

if ( ! defined( 'ABSPATH' ) ) { exit; }

class AIEO_Attribution_Backfill_Cron {

	const HOOK = 'aieo_attribution_backfill_channels';

	
	public static function maybe_schedule() {
		if ( ! wp_next_scheduled( self::HOOK ) ) {
			wp_schedule_event( time() + HOUR_IN_SECONDS, 'hourly', self::HOOK );
		}
	}

	
	public static function unschedule() {
		$ts = wp_next_scheduled( self::HOOK );
		if ( $ts ) {
			wp_unschedule_event( $ts, self::HOOK );
		}
	}

	
	public static function run() {
		if ( class_exists( 'AIEO_Attribution' ) ) {
			AIEO_Attribution::backfill_session_channels( 5000 );
		}
	}
}
