From f4e4234f9220e3d7b4b418c96c7163043262511a Mon Sep 17 00:00:00 2001 From: candiduslynx Date: Wed, 30 Aug 2023 09:20:54 +0300 Subject: [PATCH] remove stale code --- .../postgresql/client/list_tables.go | 32 ++----------------- .../destination/postgresql/client/migrate.go | 2 +- plugins/destination/postgresql/client/spec.go | 4 +-- .../services/priorities/priorities.go | 1 + .../resources/services/schedules/schedules.go | 1 + .../resources/services/charges/charges.go | 1 + .../services/checkout/checkout_sessions.go | 1 + .../services/issuing/issuing_cardholders.go | 1 + .../services/issuing/issuing_disputes.go | 1 + .../reporting/reporting_report_runs.go | 1 + .../treasury/treasury_outbound_payments.go | 1 + 11 files changed, 14 insertions(+), 32 deletions(-) diff --git a/plugins/destination/postgresql/client/list_tables.go b/plugins/destination/postgresql/client/list_tables.go index b6aad7c7d278f7..93ca251a288181 100644 --- a/plugins/destination/postgresql/client/list_tables.go +++ b/plugins/destination/postgresql/client/list_tables.go @@ -3,7 +3,6 @@ package client import ( "context" "fmt" - "strings" "github.com/cloudquery/plugin-sdk/v4/schema" ) @@ -62,12 +61,12 @@ ORDER BY table_name ASC, ordinal_position ASC; ` -func (c *Client) listTables(ctx context.Context, include []string) (schema.Tables, error) { +func (c *Client) listTables(ctx context.Context) (schema.Tables, error) { c.pgTablesToPKConstraints = map[string]string{} var tables schema.Tables - whereClause := c.whereClause(include) + var whereClause string if c.pgType == pgTypeCockroachDB { - whereClause += " AND information_schema.columns.is_hidden != 'YES'" + whereClause = " AND information_schema.columns.is_hidden != 'YES'" } q := fmt.Sprintf(selectTables, c.currentSchemaName, whereClause) rows, err := c.conn.Query(ctx, q) @@ -101,28 +100,3 @@ func (c *Client) listTables(ctx context.Context, include []string) (schema.Table } return tables, nil } - -func (c *Client) whereClause(include []string) string { - if len(include) == 0 { - return "" - } - var where string - if len(include) > 0 { - where = fmt.Sprintf("AND pg_class.relname IN (%s)", c.inClause(include)) - } - return where -} - -func (*Client) inClause(values []string) string { - var inClause string - for i, value := range values { - value = strings.ReplaceAll(value, "'", "") // strip single quotes - value = strings.ReplaceAll(value, "*", "%") // replace * with % - if i == 0 { - inClause = fmt.Sprintf("'%s'", value) - continue - } - inClause += fmt.Sprintf(", '%s'", value) - } - return inClause -} diff --git a/plugins/destination/postgresql/client/migrate.go b/plugins/destination/postgresql/client/migrate.go index 5795ac701cef97..3fb6ac14c1db2d 100644 --- a/plugins/destination/postgresql/client/migrate.go +++ b/plugins/destination/postgresql/client/migrate.go @@ -16,7 +16,7 @@ func (c *Client) MigrateTableBatch(ctx context.Context, messages message.WriteMi if err != nil { return err } - pgTables, err := c.listTables(ctx, tables.TableNames()) + pgTables, err := c.listTables(ctx) if err != nil { return fmt.Errorf("failed listing postgres tables: %w", err) } diff --git a/plugins/destination/postgresql/client/spec.go b/plugins/destination/postgresql/client/spec.go index 932a2d10dd6c4e..d7ed9e56b68880 100644 --- a/plugins/destination/postgresql/client/spec.go +++ b/plugins/destination/postgresql/client/spec.go @@ -8,8 +8,8 @@ import ( const ( defaultBatchSize = 10000 - defaultBatchSizeBytes = 1000000 - defaultBatchTimeout = 10 * time.Second + defaultBatchSizeBytes = 100000000 + defaultBatchTimeout = 60 * time.Second ) type Spec struct { diff --git a/plugins/source/pagerduty/resources/services/priorities/priorities.go b/plugins/source/pagerduty/resources/services/priorities/priorities.go index eed48178a34560..bb951137ed299a 100644 --- a/plugins/source/pagerduty/resources/services/priorities/priorities.go +++ b/plugins/source/pagerduty/resources/services/priorities/priorities.go @@ -1,6 +1,7 @@ package priorities import ( + "github.com/PagerDuty/go-pagerduty" "github.com/apache/arrow/go/v14/arrow" "github.com/cloudquery/plugin-sdk/v4/schema" "github.com/cloudquery/plugin-sdk/v4/transformers" diff --git a/plugins/source/pagerduty/resources/services/schedules/schedules.go b/plugins/source/pagerduty/resources/services/schedules/schedules.go index 5627f6f5517173..e87fc2a4823e3f 100644 --- a/plugins/source/pagerduty/resources/services/schedules/schedules.go +++ b/plugins/source/pagerduty/resources/services/schedules/schedules.go @@ -1,6 +1,7 @@ package schedules import ( + "github.com/PagerDuty/go-pagerduty" "github.com/apache/arrow/go/v14/arrow" "github.com/cloudquery/plugin-sdk/v4/schema" "github.com/cloudquery/plugin-sdk/v4/transformers" diff --git a/plugins/source/stripe/resources/services/charges/charges.go b/plugins/source/stripe/resources/services/charges/charges.go index bf36592625bb54..60b4c0f5f14679 100644 --- a/plugins/source/stripe/resources/services/charges/charges.go +++ b/plugins/source/stripe/resources/services/charges/charges.go @@ -9,6 +9,7 @@ import ( "github.com/cloudquery/cloudquery/plugins/source/stripe/client" "github.com/cloudquery/plugin-sdk/v4/schema" "github.com/cloudquery/plugin-sdk/v4/transformers" + "github.com/stripe/stripe-go/v74" ) func Charges() *schema.Table { diff --git a/plugins/source/stripe/resources/services/checkout/checkout_sessions.go b/plugins/source/stripe/resources/services/checkout/checkout_sessions.go index d9d68a22ef2f1d..4d9682814e379d 100644 --- a/plugins/source/stripe/resources/services/checkout/checkout_sessions.go +++ b/plugins/source/stripe/resources/services/checkout/checkout_sessions.go @@ -7,6 +7,7 @@ import ( "github.com/cloudquery/cloudquery/plugins/source/stripe/client" "github.com/cloudquery/plugin-sdk/v4/schema" "github.com/cloudquery/plugin-sdk/v4/transformers" + "github.com/stripe/stripe-go/v74" ) func CheckoutSessions() *schema.Table { diff --git a/plugins/source/stripe/resources/services/issuing/issuing_cardholders.go b/plugins/source/stripe/resources/services/issuing/issuing_cardholders.go index 7419716d005c41..e3b5df0574c150 100644 --- a/plugins/source/stripe/resources/services/issuing/issuing_cardholders.go +++ b/plugins/source/stripe/resources/services/issuing/issuing_cardholders.go @@ -9,6 +9,7 @@ import ( "github.com/cloudquery/cloudquery/plugins/source/stripe/client" "github.com/cloudquery/plugin-sdk/v4/schema" "github.com/cloudquery/plugin-sdk/v4/transformers" + "github.com/stripe/stripe-go/v74" ) func IssuingCardholders() *schema.Table { diff --git a/plugins/source/stripe/resources/services/issuing/issuing_disputes.go b/plugins/source/stripe/resources/services/issuing/issuing_disputes.go index 76346925ce98ec..a7ba5843de41c9 100644 --- a/plugins/source/stripe/resources/services/issuing/issuing_disputes.go +++ b/plugins/source/stripe/resources/services/issuing/issuing_disputes.go @@ -9,6 +9,7 @@ import ( "github.com/cloudquery/cloudquery/plugins/source/stripe/client" "github.com/cloudquery/plugin-sdk/v4/schema" "github.com/cloudquery/plugin-sdk/v4/transformers" + "github.com/stripe/stripe-go/v74" ) func IssuingDisputes() *schema.Table { diff --git a/plugins/source/stripe/resources/services/reporting/reporting_report_runs.go b/plugins/source/stripe/resources/services/reporting/reporting_report_runs.go index 1720303b878b54..1696f5c212c99a 100644 --- a/plugins/source/stripe/resources/services/reporting/reporting_report_runs.go +++ b/plugins/source/stripe/resources/services/reporting/reporting_report_runs.go @@ -9,6 +9,7 @@ import ( "github.com/cloudquery/cloudquery/plugins/source/stripe/client" "github.com/cloudquery/plugin-sdk/v4/schema" "github.com/cloudquery/plugin-sdk/v4/transformers" + "github.com/stripe/stripe-go/v74" ) func ReportingReportRuns() *schema.Table { diff --git a/plugins/source/stripe/resources/services/treasury/treasury_outbound_payments.go b/plugins/source/stripe/resources/services/treasury/treasury_outbound_payments.go index c0ea141fd21659..4f7ddd4c9e1b13 100644 --- a/plugins/source/stripe/resources/services/treasury/treasury_outbound_payments.go +++ b/plugins/source/stripe/resources/services/treasury/treasury_outbound_payments.go @@ -7,6 +7,7 @@ import ( "github.com/cloudquery/cloudquery/plugins/source/stripe/client" "github.com/cloudquery/plugin-sdk/v4/schema" "github.com/cloudquery/plugin-sdk/v4/transformers" + "github.com/stripe/stripe-go/v74" ) func TreasuryOutboundPayments() *schema.Table {