def get_or_fetch(self, city_name): """ get or fetch a station from a city name if multiple stations are found, this function return the first """ #try to get a place on db stations = None stations = models.get_model("skyscanner_scraper", "Station").objects.filter(name__iexact=city_name) if len(stations) == 0: #else fetch the results client = SkyscannerClient() stations = client.get_stations(city_name) if len(stations) > 0: #return the first return stations[0]
def get_or_fetch(self, city_name): """ get or fetch a station from a city name if multiple stations are found, this function return the first """ #try to get a place on db stations = None stations = models.get_model( "skyscanner_scraper", "Station").objects.filter(name__iexact=city_name) if len(stations) == 0: #else fetch the results client = SkyscannerClient() stations = client.get_stations(city_name) if len(stations) > 0: #return the first return stations[0]