Format multiline calls in geoloc service

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-07 15:10:19 +04:00
parent 3c01c87572
commit ac458e526f

View File

@@ -77,34 +77,34 @@ func (s *Service) ImportFromDir(ctx context.Context, dataDir string) error {
} }
} }
if err := s.pgClient.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error { if err := s.pgClient.WithConn(
if err := coredata.CreateIPCountryBlocksStaging(ctx, conn); err != nil { ctx,
return fmt.Errorf("cannot create staging table: %w", err) func(ctx context.Context, conn pg.Querier) error {
} if err := coredata.CreateIPCountryBlocksStaging(ctx, conn); err != nil {
return fmt.Errorf("cannot create staging table: %w", err)
}
if err := coredata.CopyIPCountryBlocksStaging(ctx, conn, blocks); err != nil { if err := coredata.CopyIPCountryBlocksStaging(ctx, conn, blocks); err != nil {
return fmt.Errorf("cannot copy IP country blocks to staging: %w", err) return fmt.Errorf("cannot copy IP country blocks to staging: %w", err)
} }
if err := coredata.FinalizeIPCountryBlocksStaging(ctx, conn); err != nil { if err := coredata.FinalizeIPCountryBlocksStaging(ctx, conn); err != nil {
return fmt.Errorf("cannot finalize staging table: %w", err) return fmt.Errorf("cannot finalize staging table: %w", err)
} }
return nil return nil
}); err != nil { },
_ = s.pgClient.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error { ); err != nil {
return coredata.DropIPCountryBlocksStaging(ctx, conn)
})
return err return err
} }
if err := s.pgClient.WithTx(ctx, func(ctx context.Context, tx pg.Tx) error { if err := s.pgClient.WithTx(
return coredata.SwapIPCountryBlocksStaging(ctx, tx) ctx,
}); err != nil { func(ctx context.Context, tx pg.Tx) error {
_ = s.pgClient.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error { return fmt.Errorf("cannot swap staging table: %w", err)
return coredata.DropIPCountryBlocksStaging(ctx, conn) },
}) ); err != nil {
return fmt.Errorf("cannot swap staging table: %w", err) return err
} }
return nil return nil