this repo has no description

fix: expects struct

Changed files
+20 -5
clickhouse_inserter
+16 -1
clickhouse_inserter/inserter.go
···
import (
"context"
"log/slog"
+
"reflect"
"slices"
"sync"
"time"
···
}
for _, d := range toInsert {
-
if err := batch.AppendStruct(&d); err != nil {
+
var structPtr any
+
if reflect.TypeOf(d).Kind() == reflect.Ptr {
+
structPtr = d
+
} else {
+
v := reflect.ValueOf(d)
+
if v.CanAddr() {
+
structPtr = v.Addr().Addr().Interface()
+
} else {
+
ptr := reflect.New(v.Type())
+
ptr.Elem().Set(v)
+
structPtr = ptr.Interface()
+
}
+
}
+
+
if err := batch.AppendStruct(structPtr); err != nil {
i.logger.Error("error appending to batch", "prefix", i.prefix, "error", err)
}
}
+3 -3
handle_create.go
···
return err
}
-
post := &models.Post{
+
post := models.Post{
Uri: uri,
Rkey: rkey,
CreatedAt: *cat,
···
return err
}
-
follow := &models.Follow{
+
follow := models.Follow{
Uri: uri,
Did: did,
Rkey: rkey,
···
return fmt.Errorf("invalid collection type %s", collection)
}
-
interaction := &models.Interaction{
+
interaction := models.Interaction{
Uri: uri,
Kind: colPts[3],
Rkey: rkey,
+1 -1
plc_scraper.go
···
continue
}
-
s.inserter.Insert(ctx, chEntry)
+
s.inserter.Insert(ctx, *chEntry)
}
}