Beispiel #1
0
func jobV2adsbHandler(r *http.Request, f *oldfdb.Flight) (string, error) {
	c := appengine.NewContext(r)
	str := ""

	if f.HasTrack("ADSB") {
		return "", nil
	} // Already has one

	err, deb := f.GetV2ADSBTrack(urlfetch.Client(c))
	str += fmt.Sprintf("*getv2ADSB [%v]:-\n", err, deb)
	if err != nil {
		return str, err
	}

	if !f.HasTrack("ADSB") {
		return "", nil
	} // Didn't find one

	f.Analyse() // Retrigger Class-B stuff

	db := oldfgae.FlightDB{C: oldappengine.NewContext(r)}
	if err := db.UpdateFlight(*f); err != nil {
		log.Errorf(c, "Persist Flight %s: %v", f, err)
		return str, err
	}
	log.Infof(c, "Updated flight %s", f)
	str += fmt.Sprintf("--\nFlight was updated\n")

	return str, nil
}
Beispiel #2
0
func jobV2adsbHandler(r *http.Request, f *oldfdb.Flight) (string, error) {
	ctx := req2ctx(r)
	str := ""

	// Allow overwrite, for the (36,0) disastery
	// if f.HasTrack("ADSB") { return "", nil } // Already has one

	err, deb := f.GetV2ADSBTrack(urlfetch.Client(ctx))
	str += fmt.Sprintf("*getv2ADSB [%v]:-\n", err, deb)
	if err != nil {
		return str, err
	}

	if !f.HasTrack("ADSB") {
		return "", nil
	} // Didn't find one

	f.Analyse() // Retrigger Class-B stuff

	db := oldfgae.NewDB(r)
	if err := db.UpdateFlight(*f); err != nil {
		log.Errorf(ctx, "Persist Flight %s: %v", f, err)
		return str, err
	}
	log.Infof(ctx, "Updated flight %s", f)
	str += fmt.Sprintf("--\nFlight was updated\n")

	return str, nil
}