๐Ÿ“ Smart Timing Logic Explained

Key Concept: The workflow runs every 14 minutes, but each website can be pinged at different intervals using mathematical calculations!

โš™๏ธ How It Works

The Magic Formula:
CURRENT_BLOCK = (RUN_NUMBER ร— 14) รท WEBSITE_INTERVAL
PREVIOUS_BLOCK = ((RUN_NUMBER-1) ร— 14) รท WEBSITE_INTERVAL

If CURRENT_BLOCK > PREVIOUS_BLOCK โ†’ PING!

๐Ÿ“Š Real Example with 4 Websites

๐Ÿš€ Website 1 (14 min)

Interval: 14 minutes

Pattern: Ping every workflow run

๐ŸŒŸ Website 2 (28 min)

Interval: 28 minutes

Pattern: Ping every 2nd workflow run

โญ Website 3 (42 min)

Interval: 42 minutes

Pattern: Ping every 3rd workflow run

๐ŸŽฏ Website 4 (56 min)

Interval: 56 minutes

Pattern: Ping every 4th workflow run

๐Ÿ“… Timeline: First 2 Hours

Workflow Run Time (Minutes) Website 1 (14min) Website 2 (28min) Website 3 (42min) Website 4 (56min)
Run 1 14 min โœ… PING โœ… PING โœ… PING โœ… PING
Run 2 28 min โœ… PING โœ… PING โŒ Skip โŒ Skip
Run 3 42 min โœ… PING โŒ Skip โœ… PING โŒ Skip
Run 4 56 min โœ… PING โœ… PING โŒ Skip โœ… PING
Run 5 70 min โœ… PING โŒ Skip โŒ Skip โŒ Skip
Run 6 84 min โœ… PING โœ… PING โœ… PING โŒ Skip
Run 7 98 min โœ… PING โŒ Skip โŒ Skip โŒ Skip
Run 8 112 min โœ… PING โœ… PING โŒ Skip โœ… PING

๐Ÿงฎ Step-by-Step Math Example

Website 2 (28-minute interval) at Run 4:

Previous Block (Run 3):
(3 ร— 14) รท 28 = 42 รท 28 = 1.5 โ†’ Block 1

Current Block (Run 4):
(4 ร— 14) รท 28 = 56 รท 28 = 2.0 โ†’ Block 2

Result: Block 2 > Block 1 โ†’ โœ… TIME TO PING!

Website 3 (42-minute interval) at Run 4:

Previous Block (Run 3):
(3 ร— 14) รท 42 = 42 รท 42 = 1.0 โ†’ Block 1

Current Block (Run 4):
(4 ร— 14) รท 42 = 56 รท 42 = 1.33 โ†’ Block 1

Result: Block 1 = Block 1 โ†’ โŒ SKIP (Not time yet)

๐ŸŽฏ Why This Is Smart

โœ… Benefits

  • Single Workflow: Manages all websites
  • Different Intervals: Each website gets its own timing
  • Parallel Execution: All pings happen simultaneously
  • Resource Efficient: One cron job instead of many

โš ๏ธ Limitations

  • Must be multiples of 14: 14, 28, 42, 56, 70...
  • Not exact timing: Some websites ping slightly early/late
  • First run special: All websites ping on the very first run
Bottom Line: Even though the workflow runs every 14 minutes, the math ensures each website only gets pinged at its specified interval!