Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/certs/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"
)

func run() error {
func Run() error {
ctx := context.Background()
// Choose DB implementation here (Mongo or SQLite)
db, err := setupMongoCertDb()
Expand Down
6 changes: 3 additions & 3 deletions tools/tpps/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,15 @@ func parseRegistry() (<-chan models.TPP, error) {
return res, nil
}

func saveTPPs(db Db, out <-chan models.TPP) error {
func saveTPPs(dbImpl db, out <-chan models.TPP) error {
batchSize := 1000
batch := make([]models.TPP, 0, batchSize)
idx := 0
for tpp := range out {
idx += 1
batch = append(batch, tpp)
if idx == batchSize {
err := db.SaveTPPs(context.TODO(), "tpps", batch)
err := dbImpl.SaveTPPs(context.TODO(), "tpps", batch)
if err != nil {
return err
}
Expand All @@ -431,7 +431,7 @@ func saveTPPs(db Db, out <-chan models.TPP) error {
}
}
if len(batch) > 0 {
err := db.SaveTPPs(context.TODO(), "tpps", batch)
err := dbImpl.SaveTPPs(context.TODO(), "tpps", batch)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions tools/tpps/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"github.com/botsman/tppVerifier/app/models"
)

type Db interface {
type db interface {
SaveTPPs(ctx context.Context, collection string, tpp []models.TPP) error
Disconnect(ctx context.Context) error
}

func run() error {
func Run() error {
// Download and parse the registry
// populate DB
// 1. Download metadata at https://euclid.eba.europa.eu/register/api/filemetadata?t=1737374419184
Expand Down