mirror of
https://github.com/woodchen-ink/random-api-go.git
synced 2025-07-18 05:42:01 +08:00
调整定期保存任务的时间间隔,从每5分钟改为每1分钟,并优化域名统计结果的排序逻辑,增加了在访问次数相同时按域名首字母排序的功能。
This commit is contained in:
parent
d944c11afb
commit
c577a827a2
@ -149,9 +149,9 @@ func (s *DomainStatsService) hasFileExtension(path string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// startPeriodicSave 启动定期保存任务(每5分钟保存一次)
|
// startPeriodicSave 启动定期保存任务(每1分钟保存一次)
|
||||||
func (s *DomainStatsService) startPeriodicSave() {
|
func (s *DomainStatsService) startPeriodicSave() {
|
||||||
ticker := time.NewTicker(5 * time.Minute)
|
ticker := time.NewTicker(1 * time.Minute)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
// 定期清理任务(每天执行一次)
|
// 定期清理任务(每天执行一次)
|
||||||
@ -287,10 +287,11 @@ 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]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,10 +346,11 @@ 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