def queued_before(unit, timestamp, summary):
    """Find how many units were queued before a given time."""
    count = 0
    for item in summary['queue']:
        if item['unit'] == unit and item['timestamp'] < timestamp:
            count += 1
    return count