mirror of
https://github.com/woodchen-ink/random-api-go.git
synced 2025-07-18 22:02:01 +08:00
Compare commits
No commits in common. "main" and "v1.0.4" have entirely different histories.
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
## 部署and讨论
|
## 部署and讨论
|
||||||
|
|
||||||
<https://www.sunai.net/t/topic/127>
|
<https://www.q58.club/t/topic/127>
|
||||||
|
|
||||||
## 许可证
|
## 许可证
|
||||||
|
|
||||||
|
@ -149,9 +149,9 @@ func (s *DomainStatsService) hasFileExtension(path string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// startPeriodicSave 启动定期保存任务(每1分钟保存一次)
|
// startPeriodicSave 启动定期保存任务(每5分钟保存一次)
|
||||||
func (s *DomainStatsService) startPeriodicSave() {
|
func (s *DomainStatsService) startPeriodicSave() {
|
||||||
ticker := time.NewTicker(1 * time.Minute)
|
ticker := time.NewTicker(5 * time.Minute)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
// 定期清理任务(每天执行一次)
|
// 定期清理任务(每天执行一次)
|
||||||
@ -287,11 +287,10 @@ func (s *DomainStatsService) GetTop24HourDomains() ([]model.DomainStatsResult, e
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按访问次数降序排序,次数相同时按域名首字母排序
|
// 按访问次数降序排序
|
||||||
for i := 0; i < len(results)-1; i++ {
|
for i := 0; i < len(results)-1; i++ {
|
||||||
for j := i + 1; j < len(results); j++ {
|
for j := i + 1; j < len(results); j++ {
|
||||||
if results[i].Count < results[j].Count ||
|
if results[i].Count < results[j].Count {
|
||||||
(results[i].Count == results[j].Count && results[i].Domain > results[j].Domain) {
|
|
||||||
results[i], results[j] = results[j], results[i]
|
results[i], results[j] = results[j], results[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,11 +345,10 @@ func (s *DomainStatsService) GetTopTotalDomains() ([]model.DomainStatsResult, er
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按访问次数降序排序,次数相同时按域名首字母排序
|
// 按访问次数降序排序
|
||||||
for i := 0; i < len(results)-1; i++ {
|
for i := 0; i < len(results)-1; i++ {
|
||||||
for j := i + 1; j < len(results); j++ {
|
for j := i + 1; j < len(results); j++ {
|
||||||
if results[i].Count < results[j].Count ||
|
if results[i].Count < results[j].Count {
|
||||||
(results[i].Count == results[j].Count && results[i].Domain > results[j].Domain) {
|
|
||||||
results[i], results[j] = results[j], results[i]
|
results[i], results[j] = results[j], results[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user