You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
676 B
41 lines
676 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.aiterp.net/rpdata/api/internal/store"
|
|
"git.aiterp.net/rpdata/api/models/channels"
|
|
"git.aiterp.net/rpdata/api/models/logs"
|
|
)
|
|
|
|
func main() {
|
|
err := store.Init()
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
return
|
|
}
|
|
|
|
logs, err := logs.List(nil)
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
return
|
|
}
|
|
|
|
added := make(map[string]bool, 1024)
|
|
for _, log := range logs {
|
|
if added[log.ChannelName] {
|
|
continue
|
|
}
|
|
|
|
_, err := channels.Ensure(log.ChannelName, false)
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, log.ID, err)
|
|
continue
|
|
}
|
|
|
|
added[log.ChannelName] = true
|
|
|
|
fmt.Println(log.ChannelName, "ensured")
|
|
}
|
|
}
|