(domain, repeaters, payload, enddate, should_create)
return missing_count
Generic method to obtain repeat records (used for Locations, Users)
    NOTE: Assumes the payload passed in was modified since the startdate
Generic method to obtain repeat records (used for Locations, Users)
    NOTE: Assumes the payload passed in was modified since the startdate
Generic method to obtain repeat records ( used for Locations Users ) NOTE : Assumes the payload passed in was modified since the startdate
def find_missing_repeat_records_in_domain(domain, repeaters, payload, enddate, should_create):
    """
    Generic method to obtain repeat records (used for Locations, Users)
    NOTE: Assumes the payload passed in was modified since the startdate
    """
    missing_count = 0
    repeat_records = get_repeat_records_by_payload_id(domain, payload.get_id)
    records_since_last_modified_date = [record for record in repeat_records
                                        if record.registered_on.date() >= payload.last_modified.date()]
    fired_repeater_ids_and_counts = defaultdict(int)
    for record in records_since_last_modified_date:
        fired_repeater_ids_and_counts[record.repeater_id] += 1

    for repeater in repeaters:
        if repeater.started_at.date() >= enddate:
            # don't count a repeater that was created after the outage
            continue

        if fired_repeater_ids_and_counts.get(repeater.get_id, 0) > 0:
            # no need to trigger a repeater if it has fired since startdate
            continue

        # if we've made it this far, the repeater should have fired
        missing_count += 1
        if should_create:
            logger.info(f"Registering {type(payload)} {payload.get_id} for repeater {repeater.get_id}")
            repeater.register(payload)
        else:
            logger.info(f"Missing {type(payload)} {payload.get_id} for repeater {repeater.get_id}")

    return missing_count
def find_missing_repeat_records_in_domain ( domain , repeaters , payload , enddate , should_create ) : missing_count = 0 repeat_records = get_repeat_records_by_payload_id ( domain , payload . get_id ) records_since_last_modified_date = [ record for record in repeat_records if record . registered_on . date ( ) >= payload . last_modified . date ( ) ] fired_repeater_ids_and_counts = defaultdict ( int ) for record in records_since_last_modified_date : fired_repeater_ids_and_counts [ record . repeater_id ] += 1 for repeater in repeaters : if repeater . started_at . date ( ) >= enddate : # don't count a repeater that was created after the outage continue if fired_repeater_ids_and_counts . get ( repeater . get_id , 0 ) > 0 : # no need to trigger a repeater if it has fired since startdate continue # if we've made it this far, the repeater should have fired missing_count += 1 if should_create : logger . info ( f"Registering {type(payload)} {payload.get_id} for repeater {repeater.get_id}" ) repeater . register ( payload ) else : logger . info ( f"Missing {type(payload)} {payload.get_id} for repeater {repeater.get_id}" ) return missing_count