本文整理汇总了Golang中github.com/mattermost/platform/utils.EndOfDay函数的典型用法代码示例。如果您正苦于以下问题:Golang EndOfDay函数的具体用法?Golang EndOfDay怎么用?Golang EndOfDay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EndOfDay函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: webrtcToken
func webrtcToken(c *Context, w http.ResponseWriter, r *http.Request) {
if token, err := getWebrtcToken(c.Session.Id); err != nil {
c.Err = err
return
} else {
result := make(map[string]string)
result["token"] = token
result["gateway_url"] = *utils.Cfg.WebrtcSettings.GatewayWebsocketUrl
if len(*utils.Cfg.WebrtcSettings.StunURI) > 0 {
result["stun_uri"] = *utils.Cfg.WebrtcSettings.StunURI
}
if len(*utils.Cfg.WebrtcSettings.TurnURI) > 0 {
timestamp := strconv.FormatInt(utils.EndOfDay(time.Now().AddDate(0, 0, 1)).Unix(), 10)
username := timestamp + ":" + *utils.Cfg.WebrtcSettings.TurnUsername
result["turn_uri"] = *utils.Cfg.WebrtcSettings.TurnURI
result["turn_password"] = generateTurnPassword(username, *utils.Cfg.WebrtcSettings.TurnSharedKey)
result["turn_username"] = username
}
w.Write([]byte(model.MapToJson(result)))
}
}
示例2: AnalyticsUserCountsWithPostsByDay
func (s SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
result := StoreResult{}
query :=
`SELECT
t1.Name, COUNT(t1.UserId) AS Value
FROM
(SELECT DISTINCT
DATE(FROM_UNIXTIME(Posts.CreateAt / 1000)) AS Name,
Posts.UserId
FROM
Posts, Channels
WHERE
Posts.ChannelId = Channels.Id`
if len(teamId) > 0 {
query += " AND Channels.TeamId = :TeamId"
}
query += ` AND Posts.CreateAt <= :EndTime
ORDER BY Name DESC) AS t1
GROUP BY Name
ORDER BY Name DESC
LIMIT 30`
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
query =
`SELECT
TO_CHAR(t1.Name, 'YYYY-MM-DD') AS Name, COUNT(t1.UserId) AS Value
FROM
(SELECT DISTINCT
DATE(TO_TIMESTAMP(Posts.CreateAt / 1000)) AS Name,
Posts.UserId
FROM
Posts, Channels
WHERE
Posts.ChannelId = Channels.Id`
if len(teamId) > 0 {
query += " AND Channels.TeamId = :TeamId"
}
query += ` AND Posts.CreateAt <= :EndTime
ORDER BY Name DESC) AS t1
GROUP BY Name
ORDER BY Name DESC
LIMIT 30`
}
end := utils.MillisFromTime(utils.EndOfDay(utils.Yesterday()))
var rows model.AnalyticsRows
_, err := s.GetReplica().Select(
&rows,
query,
map[string]interface{}{"TeamId": teamId, "EndTime": end})
if err != nil {
result.Err = model.NewAppError("SqlPostStore.AnalyticsUserCountsWithPostsByDay", "We couldn't get user counts with posts", err.Error())
} else {
result.Data = rows
}
storeChannel <- result
close(storeChannel)
}()
return storeChannel
}