Example #1
0
def merge_techs(initial, current, server):
    '''
    Merges all researched tech.
    Returns the refund that should be applied, and a new techs list to replace the old one
    '''
    tech_map, all_techs = list_to_map(initial, current, server)
    errors = []

    # Now merge each tech
    total_refund = 0
    new_techs = DuplicationList()
    for tech in all_techs:
        refund, new_tech, new_errors = merge_tech(
            tech_map["initial"].get(tech, None),
            tech_map["current"].get(tech, None),
            tech_map["server"].get(tech, None),
        )
        total_refund += refund
        errors += new_errors

        new_techs.append(new_tech)

    return total_refund, new_techs, errors
Example #2
0
def merge_reports(initial, current, server):
    """
    Merges reports based on report_id
    Expects two dictionaries of reports where each report is a dictionary
    """
    errors = []
    report_map, all_reports = list_to_map(initial, current, server)

    # Now merge each report
    total_refund = 0
    new_reports = DuplicationList()
    for report in all_reports:
        refund, new_report, new_errors = merge_report(
            report_map["initial"].get(report, None),
            report_map["current"].get(report, None),
            report_map["server"].get(report, None),
        )
        total_refund += refund
        errors += new_errors

        new_reports.append(new_report)

    return total_refund, new_reports, errors