GraphQL API and utilities for the rpdata project
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.

42 lines
657 B

  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "git.aiterp.net/rpdata/api/model/channel"
  6. "git.aiterp.net/rpdata/api/internal/store"
  7. "git.aiterp.net/rpdata/api/model/log"
  8. )
  9. func main() {
  10. err := store.Init()
  11. if err != nil {
  12. fmt.Fprintln(os.Stderr, err)
  13. return
  14. }
  15. logs, err := log.List(32768)
  16. if err != nil {
  17. fmt.Fprintln(os.Stderr, err)
  18. return
  19. }
  20. added := make(map[string]bool, 1024)
  21. for _, log := range logs {
  22. if added[log.Channel] {
  23. continue
  24. }
  25. _, err := channel.Ensure(log.Channel, false)
  26. if err != nil {
  27. fmt.Fprintln(os.Stderr, log.ID, err)
  28. continue
  29. }
  30. added[log.Channel] = true
  31. fmt.Println(log.Channel, "ensured")
  32. }
  33. }