Browse Source

rpdata-ensurechannels: Ported to use new models package.

1.0
Gisle Aune 6 years ago
parent
commit
017e68eae7
  1. 15
      cmd/rpdata-ensurechannels/main.go

15
cmd/rpdata-ensurechannels/main.go

@ -4,10 +4,9 @@ import (
"fmt" "fmt"
"os" "os"
"git.aiterp.net/rpdata/api/model/channel"
"git.aiterp.net/rpdata/api/internal/store" "git.aiterp.net/rpdata/api/internal/store"
"git.aiterp.net/rpdata/api/model/log"
"git.aiterp.net/rpdata/api/models/channels"
"git.aiterp.net/rpdata/api/models/logs"
) )
func main() { func main() {
@ -17,7 +16,7 @@ func main() {
return return
} }
logs, err := log.List(32768)
logs, err := logs.List(nil)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return return
@ -25,18 +24,18 @@ func main() {
added := make(map[string]bool, 1024) added := make(map[string]bool, 1024)
for _, log := range logs { for _, log := range logs {
if added[log.Channel] {
if added[log.ChannelName] {
continue continue
} }
_, err := channel.Ensure(log.Channel, false)
_, err := channels.Ensure(log.ChannelName, false)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, log.ID, err) fmt.Fprintln(os.Stderr, log.ID, err)
continue continue
} }
added[log.Channel] = true
added[log.ChannelName] = true
fmt.Println(log.Channel, "ensured")
fmt.Println(log.ChannelName, "ensured")
} }
} }
Loading…
Cancel
Save