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


Golang utils.EndOfDay函数代码示例

本文整理汇总了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)))
	}
}
开发者ID:Rudloff,项目名称:platform,代码行数:24,代码来源:webrtc.go

示例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
}
开发者ID:jessezwd,项目名称:platform,代码行数:71,代码来源:sql_post_store.go


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