Ejemplo n.º 1
0
func processCities(chRawCities <-chan ovio.City) {
	go func() {
		for rawCity := range chRawCities {
			city := City{
				Id:          rawCity.Code,
				Name:        rawCity.Name,
				CountryCode: rawCity.Country,
			}

			Cities[city.Id] = city

			search.AddCity(mapCity(city))
			cache.SaveCities(city.Map())
		}

		search.CreateAirportsStr()
	}()
}
Ejemplo n.º 2
0
Archivo: job.go Proyecto: Avialeta/API
func Scheduler() {
	log.Info.Print("Run Scheduler")

	if RestoreCountries() {
		RestoreCities()
		RestoreAirports()
		RestoreAirlines()

		for id := range Countries {
			search.AddCountry(mapCountry(Countries[id]))
		}

		for id := range Cities {
			search.AddCity(mapCity(Cities[id]))
		}

		for id := range Airports {
			search.AddAirport(mapAirport(Airports[id]))
		}

		search.CreateCitiesStr()
		search.CreateAirportsStr()

		log.Info.Println("Restore")
		return
	}

	chRawCountries := fetchCountries()

	chCountriesCities, chCountriesAirports := processCountries(chRawCountries)

	rawCities := fetchCities(chCountriesCities)
	rawAirports := fetchAirports(chCountriesAirports)

	processCities(rawCities)
	processAirports(rawAirports)

	go fetchAirlines()
}