当前位置: 首页>>代码示例>>Golang>>正文


Golang FlightDB.UpdateFlight方法代码示例

本文整理汇总了Golang中github.com/skypies/flightdb/gae.FlightDB.UpdateFlight方法的典型用法代码示例。如果您正苦于以下问题:Golang FlightDB.UpdateFlight方法的具体用法?Golang FlightDB.UpdateFlight怎么用?Golang FlightDB.UpdateFlight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/skypies/flightdb/gae.FlightDB的用法示例。


在下文中一共展示了FlightDB.UpdateFlight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: jobV2adsbHandler

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
}
开发者ID:hugoh,项目名称:complaints,代码行数:30,代码来源:flight-batch.go

示例2: jobTrackTimezoneHandler

func jobTrackTimezoneHandler(r *http.Request, f *oldfdb.Flight) (string, error) {
	c := appengine.NewContext(r)

	defaultTP := f.Track.ClosestTrackpoint(sfo.KFixes["EPICK"])
	adsbTP := f.Tracks["ADSB"].ClosestTrackpoint(sfo.KFixes["EPICK"])
	trackTimeDelta := defaultTP.TimestampUTC.Sub(adsbTP.TimestampUTC)

	str := fmt.Sprintf("OK, looked up %s\n Default: %s\n ADSB   : %s\n delta: %s\n",
		f, defaultTP, adsbTP, trackTimeDelta)

	if trackTimeDelta < -4*time.Hour || trackTimeDelta > 4*time.Hour {
		str += fmt.Sprintf("* recoding\n* before: %s\n", f.Tracks["ADSB"])

		for i, _ := range f.Tracks["ADSB"] {
			f.Tracks["ADSB"][i].TimestampUTC = f.Tracks["ADSB"][i].TimestampUTC.Add(time.Hour * -8)
		}
		str += fmt.Sprintf("* after : %s\n", f.Tracks["ADSB"])

		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")

	} else {
		log.Debugf(c, "Skipped flight %s, delta=%s", f, trackTimeDelta)
		str += "--\nFlight was OK, left untouched\n"
	}

	return str, nil
}
开发者ID:hugoh,项目名称:complaints,代码行数:33,代码来源:flight-batch.go

示例3: jobOceanicTagHandler

func jobOceanicTagHandler(r *http.Request, f *oldfdb.Flight) (string, error) {
	c := appengine.NewContext(r)
	str := ""

	if f.HasTag("OCEANIC") {
		return "", nil
	}
	if !f.IsOceanic() {
		return "", nil
	}

	// It's oceanic, but missing a tag ... update
	f.Tags[oldfdb.KTagOceanic] = true

	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
}
开发者ID:hugoh,项目名称:complaints,代码行数:24,代码来源:flight-batch.go

示例4: debugHandler

func debugHandler(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	db := fdb.FlightDB{C: c}
	id := r.FormValue("id")
	blob, f, err := db.GetBlobById(id)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	} else if blob == nil {
		http.Error(w, fmt.Sprintf("id=%s not found", id), http.StatusInternalServerError)
		return
	}

	blob.Flight = []byte{} // Zero this out

	s, e := f.Track.TimesInBox(sfo.KBoxSFO120K)
	log := blob.GestationLog
	blob.GestationLog = ""

	str := fmt.Sprintf("OK\n* Flight found: %s\n* Tracks: %q\n", f, f.TrackList())
	str += fmt.Sprintf("* Points in default track: %d\n", len(f.Track))
	str += fmt.Sprintf("* Default's start/end: %s, %s\n", s, e)
	str += fmt.Sprintf("\n** Gestation log:-\n%s\n", log)
	str += fmt.Sprintf("** Blob:-\n* Id=%s, Icao24=%s\n* Enter/Leave: %s -> %s\n* Tags: %v\n",
		blob.Id, blob.Icao24, blob.EnterUTC, blob.LeaveUTC, blob.Tags)

	v2URL := f.GetV2JsonUrl()
	str += "\n* V2 URL: " + v2URL + "\n"

	str += "\n**** Tracks Before\n\n"
	str += fmt.Sprintf("** %s [DEFAULT]\n", f.Track)
	for name, t := range f.Tracks {
		str += fmt.Sprintf("** %s %s\n", name, t)
	}

	err, deb := f.GetV2ADSBTrack(urlfetch.Client(c))
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	str += "\n***\n" + deb

	str += "\n**** Tracks After\n\n"
	str += fmt.Sprintf("** %s [DEFAULT]\n", f.Track)
	for name, t := range f.Tracks {
		str += fmt.Sprintf("** %s %s\n", name, t)
	}

	str += "--\nPersisting ...\n"

	if err := db.UpdateFlight(*f); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	/*

		consistent,debug := f.TracksAreConsistentDebug()
		str += fmt.Sprintf("\n** Track consistency (%v)\n\n%s\n", consistent, debug)

		//str += "\n** Default track\n"
		//for _,tp := range f.Track { str += fmt.Sprintf(" * %s\n", tp) }
	*/

	w.Header().Set("Content-Type", "text/plain")
	w.Write([]byte(str))
}
开发者ID:hugoh,项目名称:complaints,代码行数:67,代码来源:fdb.go


注:本文中的github.com/skypies/flightdb/gae.FlightDB.UpdateFlight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。