diff options
| author | Paul Buetow <paul@buetow.org> | 2024-12-25 22:43:31 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-12-25 22:43:31 +0200 |
| commit | 17b6631a084062f06dcd39da44bedcd6bc26a839 (patch) | |
| tree | 5f873b39f4fd966c30bdba228c5898a66732b473 /internal | |
| parent | f8f7b6033fc1a393d4792082419747897580f7ef (diff) | |
can fetch summary files.
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/summary/summary.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/internal/summary/summary.go b/internal/summary/summary.go index fbb601b..d76004f 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -12,23 +12,39 @@ import ( func Run(ctx context.Context, args config.Args) error { colour.Infoln("Generating summary for", args.SummaryFor) - entries := make(map[string]entry.Entry) + + entries, err := deduppedEntries(args) + if err != nil { + return err + } + fmt.Println(entries) + + return nil +} + +func deduppedEntries(args config.Args) ([]entry.Entry, error) { + dedup := make(map[string]struct{}) + var entries []entry.Entry for _, dateStr := range args.SummaryFor { glob := filepath.Join(args.GosDir, "db/platforms/*/", fmt.Sprintf("*%s*-??????.posted", dateStr)) paths, err := filepath.Glob(glob) if err != nil { - return err + return entries, err } for _, path := range paths { en, err := entry.New(path) if err != nil { - return err + return entries, err + } + if _, ok := dedup[en.Name()]; ok { + continue } - // TODO: Dedup here by name - entries[en.Name()] = en + dedup[en.Name()] = struct{}{} + entries = append(entries, en) } } - return nil + + return entries, nil } |
