Sub topic 8
Spotting Overlaps and Conflicts
A campaign calendar is only useful if it warns you about problems before they ship. The most common problem is two activities that collide. This chapter shows how to define a conflict, detect it with a small script, and avoid the errors that make automated checks noisy or wrong.
This chapter assumes you have a flat calendar table with one row per activity, including channel, owner, status, start date and end date. It also assumes you can read basic Python. The earlier chapters on the data model, the hierarchy and back-planning cover those inputs.
What counts as a conflict
Not every overlap is a problem. Two activities running in the same week is normal. A conflict is an overlap that damages results or exceeds capacity. Decide which kinds your team cares about before you write any code.
| Conflict type | Condition | Example |
|---|---|---|
| Channel collision | Same channel, date ranges intersect | Two promotional emails sent on the same days |
| Audience saturation | Same audience, intersecting dates, any channel | A customer gets an email, a push and a retargeting ad in one day |
| Owner overload | Same owner, too many due items on one date | One designer has five final assets due on Friday |
| Blackout violation | Activity falls inside a protected period | A promotion scheduled during a holiday freeze |
The tutorial's example script covers the first type. The sections below build it up and extend it to the second. Owner overload and blackouts use the same date-range logic with a different grouping key.
The interval overlap test
Each activity occupies a date range. Two ranges intersect when each one starts on or before the day the other ends:
a_start <= b_end and b_start <= a_endThis works because it only fails when one range lies completely before the other. If A ends before B starts, or B ends before A starts, there is no overlap. Every other arrangement overlaps: partial overlap, one range inside the other, or identical ranges.
Here is the pairwise check from the chapter plan, which compares every activity with every later one:
from datetime import date
activities = [
{"name": "Spring Sale email", "channel": "email", "start": date(2026, 3, 2), "end": date(2026, 3, 15)},
{"name": "Product Launch email", "channel": "email", "start": date(2026, 3, 10), "end": date(2026, 3, 20)},
{"name": "Launch blog post", "channel": "web", "start": date(2026, 3, 10), "end": date(2026, 3, 10)},
]
def overlaps(a, b):
return a["channel"] == b["channel"] and a["start"] <= b["end"] and b["start"] <= a["end"]
conflicts = [
(a["name"], b["name"])
for i, a in enumerate(activities)
for b in activities[i + 1:]
if overlaps(a, b)
]
print(conflicts) # [('Spring Sale email', 'Product Launch email')]The inner loop starts at i + 1. That compares each pair once and never compares an activity with itself. The blog post overlaps both emails in dates but is on a different channel, so it is not flagged.
For a calendar with a few hundred rows, this pairwise approach is fast enough. The number of comparisons grows with the square of the row count. If you ever check tens of thousands of rows, group the rows by channel first and sort each group by start date. Then you only compare neighbours that could still overlap.
Running the check on real calendar data
Real exports contain cancelled rows, missing end dates and inconsistent spelling. The script below loads a CSV like the one used throughout this tutorial, with one extra audience column holding semicolon-separated segment names. It cleans the rows and separates hard conflicts from soft ones.
import csv
from datetime import date
from io import StringIO
CSV_TEXT = """campaign,activity,channel,audience,owner,status,start_date,end_date
Spring Sale,Launch email,Email,customers;trial_users,Priya,in_review,2026-03-02,2026-03-02
Product Launch,Announcement email,email,customers,Dana,planned,2026-03-02,2026-03-04
Product Launch,Announcement post,web,prospects,Dana,planned,2026-03-10,
Spring Sale,Old teaser,social,customers,Marcus,cancelled,2026-03-02,2026-03-02
"""
def load_rows(text):
rows = []
for record in csv.DictReader(StringIO(text)):
if record["status"].strip().lower() == "cancelled":
continue
start = date.fromisoformat(record["start_date"])
end = date.fromisoformat(record["end_date"]) if record["end_date"] else start
audiences = {a.strip() for a in record["audience"].split(";") if a.strip()}
rows.append({
"name": f'{record["campaign"]}: {record["activity"]}',
"channel": record["channel"].strip().lower(),
"audiences": audiences,
"start": start,
"end": end,
})
return rows
def dates_overlap(a, b):
return a["start"] <= b["end"] and b["start"] <= a["end"]
def find_conflicts(rows):
found = []
for i, a in enumerate(rows):
for b in rows[i + 1:]:
if a["channel"] != b["channel"] or not dates_overlap(a, b):
continue
shared = sorted(a["audiences"] & b["audiences"])
severity = "hard" if shared else "soft"
found.append((severity, a["name"], b["name"], shared))
return found
for conflict in find_conflicts(load_rows(CSV_TEXT)):
print(conflict)
# ('hard', 'Spring Sale: Launch email', 'Product Launch: Announcement email', ['customers'])Four cleanup steps in load_rows prevent most false results:
- Cancelled rows are skipped, so dead activities never block live ones.
- A blank end date becomes the start date, which treats the entry as a single-day event.
- Channel names are lowercased and trimmed, so
Emailandemailmatch. - Audience names are split into a set, so the overlap between two audiences is a simple set intersection.
The hard and soft labels come from the audience. Two emails on the same dates to the same customers is a hard conflict, because one person may receive both. Two emails on the same dates to different segments is soft. It may be fine, but a person should confirm it.
Common errors
Inclusive and exclusive end dates
The test above treats the end date as the last day of the activity. Some tools do not. The iCalendar format stores an all-day event's DTEND as the day after the event. A one-day event on 2 March has DTSTART of 20260302 and DTEND of 20260303.
If you mix the two conventions, a one-day email on 2 March appears to run until 3 March. It then falsely conflicts with an email on 3 March. Pick one convention for your internal data and convert at the boundary:
from datetime import date, timedelta
def ics_end_to_inclusive(dtend: date) -> date:
"""Convert an all-day iCalendar DTEND (exclusive) to the last day (inclusive)."""
return dtend - timedelta(days=1)
print(ics_end_to_inclusive(date(2026, 3, 3))) # 2026-03-02If you prefer exclusive ends internally, the test changes to strict comparisons: a_start < b_end and b_start < a_end. Mixing the two forms in one script is the real mistake.
Date-times and time zones
The scripts use date values, which suits all-day planning. Once entries carry a send time, such as an email at 09:00 in one region, compare timezone-aware datetime values. Mixing naive and aware values raises an error in Python. Comparing local times from different regions silently gives wrong answers.
Intentional overlap inside one campaign
A single campaign often runs several activities on one channel at once, such as a teaser sequence of three emails. Flagging all of them is noise. Compare the campaign field and skip pairs from the same campaign, or flag them only when the audiences are identical and the dates are the same day.
Alert fatigue
If the check reports forty items every week, people stop reading it. Report hard conflicts first, group results by week, and tune the rules. Raise a rule's threshold or drop a rule that nobody acts on.
Deciding what happens when a conflict is found
Detection is half the job. Agree in advance on who resolves a conflict and how:
- The report goes to the owners of both activities, not just one.
- The owners propose a fix: shift the dates, merge the sends, or change the audience.
- If they cannot agree, the calendar manager or channel lead decides.
- The calendar is updated and the check is re-run before the activity moves to the next status.
A good rule is to run the check when an activity moves from draft to in_review. At that point, changing a date is still cheap. Running it only on launch day produces last-minute disputes.
Exercises
Exercise
Activity A runs 1 March to 5 March and activity B runs 5 March to 9 March, both on email, with inclusive end dates. Does the check a_start <= b_end and b_start <= a_end flag them? Would your answer change if the end dates were exclusive?
Show answer
Yes, it flags them, because 1 March <= 9 March and 5 March <= 5 March are both true. They share 5 March. If the end dates were exclusive, A would end before 5 March starts, so they would not overlap. The strict test a_start < b_end and b_start < a_end gives 5 < 5 as false, so they are not flagged. You must apply one convention consistently.
Exercise
A calendar export from an iCalendar tool shows a one-day social post with DTSTART 20260310 and DTEND 20260311. A second post is scheduled for 11 March. Your script uses inclusive end dates and the raw DTEND values. What goes wrong, and how do you fix it?
Show answer
The first post is loaded as running 10 to 11 March, so it falsely overlaps the post on 11 March. Fix it by subtracting one day from the all-day DTEND when importing, so the first post ends on 10 March, then compare using inclusive dates.
Exercise
Two emails overlap in dates and are on the same channel. One targets "customers" and the other targets "prospects". Using the severity rule in this chapter, how is the pair labeled, and why might a person still want to review it?
Show answer
It is labeled soft, because the audiences share no members. A person may still review it if the segments overlap in practice, for example when a prospect later becomes a customer, or if the channel has a send-volume limit that affects deliverability.