diff --git a/langserver/internal/bigquery/bigquery.go b/langserver/internal/bigquery/bigquery.go index 6882308..0da1e4b 100644 --- a/langserver/internal/bigquery/bigquery.go +++ b/langserver/internal/bigquery/bigquery.go @@ -77,7 +77,7 @@ func (c *client) GetDefaultProject() string { } func (c *client) ListProjects(ctx context.Context) ([]*cloudresourcemanager.Project, error) { - caller := c.cloudresourcemanagerService.Projects.List().Context(ctx) + caller := c.cloudresourcemanagerService.Projects.List().PageSize(1000).Context(ctx) list, err := caller.Do() if err != nil { diff --git a/langserver/internal/bigquery/cache.go b/langserver/internal/bigquery/cache.go index c97369a..9fbb86a 100644 --- a/langserver/internal/bigquery/cache.go +++ b/langserver/internal/bigquery/cache.go @@ -83,10 +83,14 @@ func (c *cache) callListProjects(ctx context.Context) ([]*cloudresourcemanager.P } if len(result) > 0 { - err := c.db.InsertProjects(ctx, result) - if err != nil { - // TODO - fmt.Fprintf(os.Stderr, "failed to insert projects: %v\n", err) + insertSize := 1000 + for i := 0; i < len(result); i += insertSize { + insertItems := result[i:min(len(result), i+insertSize)] + err := c.db.InsertProjects(ctx, insertItems) + if err != nil { + // TODO + fmt.Fprintf(os.Stderr, "failed to insert projects: %v\n", err) + } } } return result, nil