From d8ae5f3ec954800ecdf613860f761beb5acf7caf Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 3 Aug 2016 16:35:02 +0200 Subject: get sorted list of carts diff --git a/src/pool-import/main.go b/src/pool-import/main.go index dfa6ab5..b184ef3 100644 --- a/src/pool-import/main.go +++ b/src/pool-import/main.go @@ -24,6 +24,7 @@ package main import ( "log" "os" + "sort" "code.helsinki.at/rhrd-go/rddb" "code.helsinki.at/rhrd-go/rhimport" @@ -74,4 +75,22 @@ func main() { } log.Printf("will import: %d carts from old:%s -> new:%s", len(carts), old_group, new_group) + + var keys []int + for k := range carts { + keys = append(keys, int(k)) + } + sort.Ints(keys) + for _, k := range keys { + cart := carts[uint(k)] + if len(cart.Cuts) == 0 { + log.Printf("Warning: Cart %d has no cuts - ingoring it", cart.Number) + continue + } else if len(cart.Cuts) > 1 { + log.Printf("Warning: Cart %d has multiple cuts - will only use the first", cart.Number) + } + cut := cart.Cuts[0].Number + log.Printf(" %06d_%03d: '%s' / '%s' / '%s'", cart.Number, cut, cart.Artist, cart.Album, cart.Title) + + } } -- cgit v0.10.2