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


Golang Complaint.DatastoreKey方法代码示例

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


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

示例1: FixupComplaint

func FixupComplaint(c *types.Complaint, key *datastore.Key) {
	// 0. Snag the key, so we can refer to this object later
	c.DatastoreKey = key.Encode()

	// 1. GAE datastore helpfully converts timezones to UTC upon storage; fix that
	c.Timestamp = date.InPdt(c.Timestamp)

	// 2. Compute the flight details URL, if within 24 days
	age := date.NowInPdt().Sub(c.Timestamp)
	if age < time.Hour*24 {
		// c.AircraftOverhead.Fr24Url = c.AircraftOverhead.PlaybackUrl()

		c.AircraftOverhead.Fr24Url = "http://flightaware.com/live/flight/" +
			c.AircraftOverhead.FlightNumber
		// Or: http://flightaware.com/live/flight/UAL337/history/20151215/ [0655Z/KLAX/KSFO]
		// date is UTC of departure time; might be tricky to guess :/
	}

	// 3. Compute distances, if we have an aircraft
	if c.AircraftOverhead.FlightNumber != "" {
		a := c.AircraftOverhead
		aircraftPos := geo.Latlong{a.Lat, a.Long}
		observerPos := geo.Latlong{c.Profile.Lat, c.Profile.Long}
		c.Dist2KM = observerPos.Dist(aircraftPos)
		c.Dist3KM = observerPos.Dist3(aircraftPos, a.Altitude)
	}
}
开发者ID:skypies,项目名称:complaints,代码行数:27,代码来源:complaint.go

示例2: form2Complaint

func form2Complaint(r *http.Request) types.Complaint {
	c := types.Complaint{
		Description:      r.FormValue("content"),
		Timestamp:        time.Now(), // No point setting a timezone, it gets reset to UTC
		HeardSpeedbreaks: FormValueCheckbox(r, "speedbrakes"),
		Loudness:         int(FormValueInt64(r, "loudness")),
		Activity:         r.FormValue("activity"),
		Browser: types.Browser{
			UUID:     r.FormValue("browser_uuid"),
			Name:     r.FormValue("browser_name"),
			Version:  r.FormValue("browser_version"),
			Vendor:   r.FormValue("browser_vendor"),
			Platform: r.FormValue("browser_platform"),
		},
	}

	// This field is set during updates (it identifies a complaint to update)
	if r.FormValue("datastorekey") != "" {
		c.DatastoreKey = r.FormValue("datastorekey")
	}

	// These fields are set directly in CGI args, for historical population
	if r.FormValue("timestamp_epoch") != "" {
		c.Timestamp = time.Unix(FormValueInt64(r, "timestamp_epoch"), 0)
	}
	if r.FormValue("flight") != "" {
		c.AircraftOverhead.FlightNumber = r.FormValue("flight")
	}

	return c
}
开发者ID:skypies,项目名称:complaints,代码行数:31,代码来源:add-complaint.go

示例3: Overwrite

// Overwrite user-entered data (and timestamp) into the base complaint.
func Overwrite(this, from *types.Complaint) {
	orig := *this // Keep a temp copy
	*this = *from // Overwrite everything

	// Restore a few key fields from the original
	this.DatastoreKey = orig.DatastoreKey

	// If the orig had a description but new doesn't, don't lose it
	if this.Description == "" && orig.Description != "" {
		this.Description = orig.Description
	}
}
开发者ID:skypies,项目名称:complaints,代码行数:13,代码来源:complaint.go


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