Skip to content

Commit

Permalink
Adding notification that id is missing certain image types while gett…
Browse files Browse the repository at this point in the history
…ing image for that id
  • Loading branch information
boggydigital committed Sep 27, 2023
1 parent 1bcd3a9 commit 9a0d12b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cli/get_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/boggydigital/nod"
"net/url"
"path/filepath"
"strings"
)

func GetImagesHandler(u *url.URL) error {
Expand Down Expand Up @@ -93,6 +94,7 @@ func GetImages(
}

mita := nod.NewProgress("%s %s", id, title)
missingImageTypes := map[vangogh_local_data.ImageType]bool{}

//sensible assumption - we'll have at least as many URLs and filenames
//as types of images we're missing
Expand All @@ -103,6 +105,8 @@ func GetImages(

images, ok := rxa.GetAllValues(vangogh_local_data.PropertyFromImageType(it), id)
if !ok || len(images) == 0 {
nod.Log("%s missing %s", id, it)
missingImageTypes[it] = true
continue
}

Expand Down Expand Up @@ -130,7 +134,16 @@ func GetImages(
return mita.EndWithError(err)
}

mita.EndWithResult("done")
completionStatus := "done"
if len(missingImageTypes) > 0 {
itss := make([]string, 0, len(missingImageTypes))
for it := range missingImageTypes {
itss = append(itss, it.String())
}
completionStatus = fmt.Sprintf("no %s", strings.Join(itss, ", "))
}

mita.EndWithResult(completionStatus)
gia.Increment()
}

Expand Down

0 comments on commit 9a0d12b

Please sign in to comment.