2025-09-19 16:17:46 +08:00
|
|
|
package data
|
2025-10-23 18:02:29 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"datart/data/influx"
|
2025-11-06 21:09:50 +08:00
|
|
|
"datart/data/postgres"
|
2025-10-23 18:02:29 +08:00
|
|
|
|
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Process struct {
|
|
|
|
|
cancel context.CancelFunc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewProcess() *Process {
|
|
|
|
|
return new(Process)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *Process) StartDataProcessing() {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
p.cancel = cancel
|
2025-11-06 21:09:50 +08:00
|
|
|
postgres.GenSSU2ChannelSizes(ctx, 500)
|
2025-10-23 18:02:29 +08:00
|
|
|
updatingRedisPhasor(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *Process) Cancel() {
|
|
|
|
|
p.cancel()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type zUnit struct {
|
|
|
|
|
Key string
|
|
|
|
|
Members []redis.Z
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func convertTVsToMenmbers(tvs []influx.TV) []redis.Z {
|
|
|
|
|
members := make([]redis.Z, len(tvs))
|
|
|
|
|
|
|
|
|
|
for i, tv := range tvs {
|
|
|
|
|
members[i].Member = tv.Time
|
|
|
|
|
members[i].Score = tv.Value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return members
|
|
|
|
|
}
|