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.

41 lines
676 B

  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "git.aiterp.net/rpdata/api/internal/store"
  6. "git.aiterp.net/rpdata/api/models/channels"
  7. "git.aiterp.net/rpdata/api/models/logs"
  8. )
  9. func main() {
  10. err := store.Init()
  11. if err != nil {
  12. fmt.Fprintln(os.Stderr, err)
  13. return
  14. }
  15. logs, err := logs.List(nil)
  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.ChannelName] {
  23. continue
  24. }
  25. _, err := channels.Ensure(log.ChannelName, false)
  26. if err != nil {
  27. fmt.Fprintln(os.Stderr, log.ID, err)
  28. continue
  29. }
  30. added[log.ChannelName] = true
  31. fmt.Println(log.ChannelName, "ensured")
  32. }
  33. }