def get_top_level_locations(self, characterIDs, regionID=None): asset_locations = self.filter(owner__in=characterIDs) if regionID: asset_locations = asset_locations.filter(regionID=regionID) asset_locations = asset_locations.distinct('locationID'). \ values_list('locationID', flat=True) locations = [get_location(locationID) for locationID in asset_locations] out = [] for location in locations: if type(location) is long: locationID = location else: locationID = location.pk out.append({'regionName': get_location_regionName(location), 'regionID': get_location_regionID(location), 'solarSystemName': get_location_solarSystemName(location), 'solarSystemID': get_location_solarSystemID(location), 'name': get_location_name(locationID), 'locationID': locationID}) return out
def annotate_locations(self, asset_locations): for asset_location in asset_locations: locationID = asset_location['locationID'] location_key = self._location_data_key(locationID) location_data = self._cache_get(location_key) if not location_data: location = get_location(locationID) location_data = { 'regionName': get_location_regionName(location), 'regionID': get_location_regionID(location), 'solarSystemName': get_location_solarSystemName(location), 'solarSystemID': get_location_solarSystemID(location), 'name': get_location_name(locationID) } self._cache_data(location_key, location_data) asset_location.update(location_data)