summaryrefslogtreecommitdiff
path: root/internal/summary/summary.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-11 23:09:28 +0200
committerPaul Buetow <paul@buetow.org>2024-12-11 23:09:28 +0200
commit121d2877cc7ed0aaf0bbe5c57b86abba982b0441 (patch)
tree46893a05b71aaf6b25e971adda6126ae766eae7b /internal/summary/summary.go
parent0f5ecb2715876d05bed8e54d7bd30754e57bcdc4 (diff)
initial summary support
Diffstat (limited to 'internal/summary/summary.go')
-rw-r--r--internal/summary/summary.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/summary/summary.go b/internal/summary/summary.go
new file mode 100644
index 0000000..ca38620
--- /dev/null
+++ b/internal/summary/summary.go
@@ -0,0 +1,52 @@
+package summary
+
+import (
+ "context"
+ "fmt"
+ "path/filepath"
+
+ "codeberg.org/snonux/gos/internal/colour"
+ "codeberg.org/snonux/gos/internal/config"
+ "codeberg.org/snonux/gos/internal/entry"
+)
+
+func Run(ctx context.Context, args config.Args) error {
+ colour.Infoln("Generating summary for", args.SummaryFor)
+ entries := make(map[string]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
+ }
+ for _, path := range paths {
+ en, err := entry.New(path)
+ if err != nil {
+ return err
+ }
+ // TODO: Dedup here by name
+ entries[en.Name()] = en
+ }
+ }
+ // ch, err := oi.ReadDirCh(args.GosDir, find(args.GosDir, validExtensions...))
+ // if err != nil {
+ // return err
+ // }
+
+ // for filePath := range ch {
+ return nil
+}
+
+// func find(path string, suffixes ...string) func(os.DirEntry) (string, bool) {
+// return func(file os.DirEntry) (string, bool) {
+// filePath := filepath.Join(path, file.Name())
+// for _, suffix := range suffixes {
+// if strings.HasSuffix(file.Name(), suffix) {
+// return filePath, true
+// }
+// }
+// return filePath, false
+// }
+// }