本文整理匯總了Golang中github.com/ginuerzh/sports/models.RedisLogger.TaskSharers方法的典型用法代碼示例。如果您正苦於以下問題:Golang RedisLogger.TaskSharers方法的具體用法?Golang RedisLogger.TaskSharers怎麽用?Golang RedisLogger.TaskSharers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ginuerzh/sports/models.RedisLogger
的用法示例。
在下文中一共展示了RedisLogger.TaskSharers方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: taskReferralsHandler
func taskReferralsHandler(r *http.Request, w http.ResponseWriter,
redis *models.RedisLogger, user *models.Account) {
if user.Taskid > len(models.NewTasks) {
writeResponse(r.RequestURI, w, nil, errors.NewError(errors.AccessError))
return
}
task := models.NewTasks[user.Taskid]
excludes := redis.TaskSharers()
friends := redis.Friends(models.RelFriend, user.Id)
excludes = append(excludes, user.Id)
excludes = append(excludes, friends...)
users, _ := user.TaskReferrals(task.Type, excludes)
var referrals []*referral
for i, _ := range users {
ref := &referral{
Userid: users[i].Id,
Nickname: users[i].Nickname,
Profile: users[i].Profile,
Gender: users[i].Gender,
Images: users[i].Photos,
Birthday: users[i].Birth,
Lastlog: users[i].LastLogin.Unix(),
Location: users[i].Loc,
}
if users[i].Ratios.RunRecv > 0 {
ref.RunRatio = float32(users[i].Ratios.RunAccept) / float32(users[i].Ratios.RunRecv)
}
if users[i].Ratios.PostRecv > 0 {
ref.PostRatio = float32(users[i].Ratios.PostAccept) / float32(users[i].Ratios.PostRecv)
}
if users[i].Ratios.PKRecv > 0 {
ref.PkRatio = float32(users[i].Ratios.PKAccept) / float32(users[i].Ratios.PKRecv)
}
if task.Type == models.TaskRunning || task.Type == models.TaskGame {
rec, _ := users[i].LastRecord("run")
ref.LastId = rec.Id.Hex()
ref.LastTime = rec.PubTime.Unix()
} else if task.Type == models.TaskPost {
article := users[i].LatestArticle()
ref.LastId = article.Id.Hex()
ref.LastTime = article.PubTime.Unix()
}
referrals = append(referrals, ref)
}
respData := map[string]interface{}{"referrals": referrals}
writeResponse(r.RequestURI, w, respData, nil)
}