Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Tweaked prints.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Mar 30, 2021
1 parent 3f53812 commit f22b663
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
17 changes: 6 additions & 11 deletions lib/cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,38 @@ var newCmd = &cobra.Command{
fix database`,
Run: func(cmd *cobra.Command, args []string) {
config.Check()
// demozoo handler
color.Info.Println("Scan for new demozoo submissions")
dz := demozoo.Request{
All: false,
Overwrite: false,
Refresh: false,
Simulate: false,
}
color.Info.Println("scan for new demozoo submissions")
if err := dz.Queries(); err != nil {
logs.Fatal(err)
}
// proofs handler
color.Info.Println("Scan for new proof submissions")
p := proof.Request{
Overwrite: false,
AllProofs: false,
HideMissing: false,
}
color.Info.Println("scan for new proof submissions")
if err := p.Queries(); err != nil {
logs.Fatal(err)
}
// missing image previews
color.Info.Println("generate missing images")
color.Info.Println("Generate missing images")
if err := images.Fix(false); err != nil {
logs.Fatal(err)
}
// missing text file previews
color.Info.Println("generate missing text previews")
color.Info.Println("Generate missing text previews")
if err := text.Fix(false); err != nil {
logs.Fatal(err)
}
// fix database entries
color.Info.Println("fix demozoo data conflicts")
color.Info.Println("Fix demozoo data conflicts")
if err := demozoo.Fix(); err != nil {
log.Fatal(err)
}
color.Info.Println("fix malformed database entries")
color.Info.Println("Fix malformed database entries")
if err := database.Fix(); err != nil {
log.Fatal(err)
}
Expand Down
10 changes: 7 additions & 3 deletions lib/demozoo/demozoo.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ func (req Request) Queries() error {
if err = st.sumTotal(records{rows, scanArgs, values}, req); err != nil {
return fmt.Errorf("req queries sum total: %w", err)
}
if st.total > 1 {
if st.total == 0 {
logs.Println("nothing to do")
} else {
logs.Println("Total records", st.total)
}
rows, err = db.Query(stmt)
Expand All @@ -182,7 +184,6 @@ func (req Request) Queries() error {
logs.Danger(fmt.Errorf("request queries new record: %w", err))
continue
}
fmt.Println()
logs.Printcrf(r.String(st.total))
if update := r.check(); !update {
continue
Expand All @@ -208,6 +209,9 @@ func (req Request) Queries() error {
st.print()
return nil
}
if st.total > 0 {
fmt.Println()
}
st.summary(time.Since(start))
return nil
}
Expand Down Expand Up @@ -256,7 +260,7 @@ func (st stat) print() {

func (st stat) summary(elapsed time.Duration) {
t := fmt.Sprintf("Total Demozoo items handled: %v, time elapsed %.1f seconds", st.count, elapsed.Seconds())
logs.Println("\n" + strings.Repeat("─", len(t)))
logs.Println(strings.Repeat("─", len(t)))
logs.Println(t)
if st.missing > 0 {
logs.Println("UUID files not found:", st.missing)
Expand Down

0 comments on commit f22b663

Please sign in to comment.