當前位置: 首頁>>代碼示例>>Golang>>正文


Golang RedisLogger.Onlines方法代碼示例

本文整理匯總了Golang中github.com/ginuerzh/sports/models.RedisLogger.Onlines方法的典型用法代碼示例。如果您正苦於以下問題:Golang RedisLogger.Onlines方法的具體用法?Golang RedisLogger.Onlines怎麽用?Golang RedisLogger.Onlines使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ginuerzh/sports/models.RedisLogger的用法示例。


在下文中一共展示了RedisLogger.Onlines方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: summaryHandler

func summaryHandler(w http.ResponseWriter, redis *models.RedisLogger, form summaryForm) {
	if ok, err := checkToken(redis, form.Token); !ok {
		writeResponse(w, err)
		return
	}

	var stats struct {
		RegPhone      []int64 `json:"reg_phone"`
		RegEmail      []int64 `json:"reg_email"`
		RegWeibo      []int64 `json:"reg_weibo"`
		Registers     []int64 `json:"registers"`
		Logins        []int64 `json:"logins"`
		CoachLogins   []int64 `json:"coach_logins"`
		Actives       []int64 `json:"actives"`
		PostUsers     []int64 `json:"post_users"`
		Posts         []int64 `json:"posts"`
		Gamers        []int64 `json:"gamers"`
		GameTime      []int64 `json:"game_time"`
		RecordUsers   []int64 `json:"record_users"`
		AuthCoaches   []int64 `json:"auth_coaches"`
		Coins         []int64 `json:"coins"`
		Users         int     `json:"users"`
		Onlines       int     `json:"onlines"`
		OnlineCoaches int     `json:"online_coaches"`
	}
	days := form.Days
	if days <= 0 {
		days = 3
	}
	//var start, end time.Time
	//start, end = now.BeginningOfDay(), now.EndOfDay()

	stats.RegPhone = redis.RegisterCount(days, models.AccountPhone)
	stats.RegEmail = redis.RegisterCount(days, models.AccountEmail)
	stats.RegWeibo = redis.RegisterCount(days, models.AccountWeibo)
	stats.Registers = redis.RegisterCount(days, "")
	stats.Logins = redis.LoginCount(days)
	stats.CoachLogins = redis.CoachLoginCount(days)
	actives := make([]int64, days)
	for i := 0; i < days; i++ {
		actives[i] = stats.Logins[i] - stats.Registers[i]
	}
	stats.Actives = actives
	stats.PostUsers = redis.PostUserCount(days)
	stats.Posts = redis.PostsCount(days)
	stats.Gamers = redis.GamersCount(days)
	stats.GameTime = redis.GameTime(days)
	stats.RecordUsers = redis.RecordUsersCount(days)
	stats.AuthCoaches = redis.AuthCoachesCount(days)
	stats.Coins = redis.CoinsCount(days)
	stats.Users = models.UserCount()
	stats.Onlines = redis.Onlines()

	writeResponse(w, stats)
}
開發者ID:shevilangle,項目名稱:sports,代碼行數:55,代碼來源:stat.go


注:本文中的github.com/ginuerzh/sports/models.RedisLogger.Onlines方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。