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
8 changes: 4 additions & 4 deletions tools/certs/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ package certsdb
import (
"context"
"fmt"
"log"
"net/http"
"time"
)

func run() {
func run() error {
ctx := context.Background()
// Choose DB implementation here (Mongo or SQLite)
db, err := setupMongoCertDb()
// db, err := setupSqliteCertDb("data/sqlite.db")
if err != nil {
log.Fatalf("DB setup failed: %v", err)
return fmt.Errorf("DB setup failed: %w", err)
}
defer db.Disconnect(ctx)

Expand All @@ -36,8 +35,9 @@ func run() {

modified, err := db.CleanupInactive(ctx, now)
if err != nil {
fmt.Println("Error updating inactive certificates:", err)
return fmt.Errorf("error updating inactive certificates: %w", err)
}
fmt.Println("Finished processing certificates at", nowStr)
fmt.Printf("Updated %d certificates to inactive\n", modified)
return nil
}
12 changes: 4 additions & 8 deletions tools/tpps/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tppsdb

import (
"context"
"log"

"github.com/botsman/tppVerifier/app/models"
)
Expand All @@ -12,7 +11,7 @@ type Db interface {
Disconnect(ctx context.Context) error
}

func run() {
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 All @@ -26,16 +25,13 @@ func run() {

tppChan, err := parseRegistry()
if err != nil {
log.Fatal(err)
return err
}
client, err := setupMongoDb()
// client, err := setupSqliteDb("data/sqlite.db")
if err != nil {
panic(err)
return err
}
defer client.Disconnect(context.TODO())
err = saveTPPs(client, tppChan)
if err != nil {
log.Fatal(err)
}
return saveTPPs(client, tppChan)
}