(domain, filters)
return locations
Returns a list of locations, with the user's filters applied.
Returns a list of locations, with the user's filters applied.
Returns a list of locations with the user s filters applied .
def get_locations(domain, filters) -> List[LocationTuple]:
    """
    Returns a list of locations, with the user's filters applied.
    """
    level_1s, l2s_by_l1, l3s_by_l2, l4s_by_l3 = get_sorted_levels(domain, filters)

    locations = []
    for level_1 in level_1s:
        for level_2 in l2s_by_l1[level_1['id']]:
            if not l3s_by_l2:
                locations.append(LocationTuple(
                    id=level_2['id'],
                    name=level_2['name'],
                    country=level_1['country'],
                    level_1=level_1['name'],
                    level_2=level_2['name'],
                    level_3=None,
                    level_4=None,
                ))
            else:
                for level_3 in l3s_by_l2[level_2['id']]:
                    if not l4s_by_l3:
                        locations.append(LocationTuple(
                            id=level_3['id'],
                            name=level_3['name'],
                            country=level_1['country'],
                            level_1=level_1['name'],
                            level_2=level_2['name'],
                            level_3=level_3['name'],
                            level_4=None,
                        ))
                    else:
                        for level_4 in l4s_by_l3[level_3['id']]:
                            locations.append(LocationTuple(
                                id=level_4['id'],
                                name=level_4['name'],
                                country=level_1['country'],
                                level_1=level_1['name'],
                                level_2=level_2['name'],
                                level_3=level_3['name'],
                                level_4=level_4['name'],
                            ))
    return locations
def get_locations ( domain , filters ) -> List [ LocationTuple ] : level_1s , l2s_by_l1 , l3s_by_l2 , l4s_by_l3 = get_sorted_levels ( domain , filters ) locations = [ ] for level_1 in level_1s : for level_2 in l2s_by_l1 [ level_1 [ 'id' ] ] : if not l3s_by_l2 : locations . append ( LocationTuple ( id = level_2 [ 'id' ] , name = level_2 [ 'name' ] , country = level_1 [ 'country' ] , level_1 = level_1 [ 'name' ] , level_2 = level_2 [ 'name' ] , level_3 = None , level_4 = None , ) ) else : for level_3 in l3s_by_l2 [ level_2 [ 'id' ] ] : if not l4s_by_l3 : locations . append ( LocationTuple ( id = level_3 [ 'id' ] , name = level_3 [ 'name' ] , country = level_1 [ 'country' ] , level_1 = level_1 [ 'name' ] , level_2 = level_2 [ 'name' ] , level_3 = level_3 [ 'name' ] , level_4 = None , ) ) else : for level_4 in l4s_by_l3 [ level_3 [ 'id' ] ] : locations . append ( LocationTuple ( id = level_4 [ 'id' ] , name = level_4 [ 'name' ] , country = level_1 [ 'country' ] , level_1 = level_1 [ 'name' ] , level_2 = level_2 [ 'name' ] , level_3 = level_3 [ 'name' ] , level_4 = level_4 [ 'name' ] , ) ) return locations