getChatRank 获得水群排名,时间单位为秒
(gid int64)
| 154 | |
| 155 | // getChatRank 获得水群排名,时间单位为秒 |
| 156 | func (ctdb *chattimedb) getChatRank(gid int64) (chatTimeList []chatTime) { |
| 157 | ctdb.chatmu.Lock() |
| 158 | defer ctdb.chatmu.Unlock() |
| 159 | chatTimeList = make([]chatTime, 0, 100) |
| 160 | keyList := make([]string, 0, 100) |
| 161 | ctdb.userTimestampMap.Range(func(key string, value int64) bool { |
| 162 | t := time.Unix(value, 0) |
| 163 | if strings.Contains(key, strconv.FormatInt(gid, 10)) && t.YearDay() == time.Now().YearDay() { |
| 164 | keyList = append(keyList, key) |
| 165 | } |
| 166 | return true |
| 167 | }) |
| 168 | for _, v := range keyList { |
| 169 | _, a, _ := strings.Cut(v, "_") |
| 170 | uid, _ := strconv.ParseInt(a, 10, 64) |
| 171 | todayTime, _ := ctdb.userTodayTimeMap.Load(v) |
| 172 | todayMessage, _ := ctdb.userTodayMessageMap.Load(v) |
| 173 | chatTimeList = append(chatTimeList, chatTime{ |
| 174 | GroupID: gid, |
| 175 | UserID: uid, |
| 176 | TodayTime: todayTime, |
| 177 | TodayMessage: todayMessage, |
| 178 | }) |
| 179 | } |
| 180 | sort.Sort(sortChatTime(chatTimeList)) |
| 181 | return |
| 182 | } |
| 183 | |
| 184 | // leveler 结构体,包含一个 levelArray 字段 |
| 185 | type leveler struct { |
no test coverage detected