CREATE OR REPLACE TASK AGG_USER_TO_USER_ENGAGEMENT_WEEKLY_INSERT
    WAREHOUSE = SUNO_PROD_X_SMAL
    SCHEDULE = 'USING CRON 0 0 * * 1 UTC'
AS 
DECLARE
    p_date VARCHAR;
    row_count NUMBER;
    start_time TIMESTAMP;
BEGIN
    start_time := CURRENT_TIMESTAMP();
    p_date := CURRENT_DATE();
    CALL agg_user_to_user_engagement_weekly_proc(:p_date);  

    SELECT COUNT(*) INTO :row_count
    FROM SUNO_PROD.PROD.AGG_USER_TO_USER_ENGAGEMENT_WEEKLY
    WHERE p_date = :p_date;
    CALL TASK_MONITOR_INSERT_PROC('AGG_USER_TO_USER_ENGAGEMENT_WEEKLY_INSERT', :start_time, :row_count, 'SUCCESS', 'WEEKLY');
END; 