mindlesscloud commented on code in PR #2011: URL: https://github.com/apache/incubator-devlake/pull/2011#discussion_r881757868
########## plugins/tapd/tasks/bug_custom_fields_extractor.go: ########## @@ -0,0 +1,72 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package tasks + +import ( + "encoding/json" + "github.com/apache/incubator-devlake/plugins/core" + "github.com/apache/incubator-devlake/plugins/helper" + "github.com/apache/incubator-devlake/plugins/tapd/models" +) + +var _ core.SubTaskEntryPoint = ExtractBugCustomFields + +var ExtractBugCustomFieldsMeta = core.SubTaskMeta{ + Name: "extractBugCustomFields", + EntryPoint: ExtractBugCustomFields, + EnabledByDefault: true, + Description: "Extract raw company data into tool layer table _tool_tapd_bug_custom_fields", +} + +type TapdBugCustomFieldsRes struct { + CustomFieldConfig models.TapdBugCustomFields +} + +func ExtractBugCustomFields(taskCtx core.SubTaskContext) error { + data := taskCtx.GetData().(*TapdTaskData) + extractor, err := helper.NewApiExtractor(helper.ApiExtractorArgs{ + RawDataSubTaskArgs: helper.RawDataSubTaskArgs{ + Ctx: taskCtx, + Params: TapdApiParams{ + ConnectionId: data.Connection.ID, + WorkspaceID: data.Options.WorkspaceID, + }, + Table: RAW_BUG_CUSTOM_FIELDS_TABLE, + }, + Extract: func(row *helper.RawData) ([]interface{}, error) { + var customFields TapdBugCustomFieldsRes Review Comment: If the struct `TapdBugCustomFieldsRes` is not referenced in other files, it could be replaced by an anonymous struct ```go var customFields struct { CustomFieldConfig models.TapdBugCustomFields } ``` ########## plugins/tapd/tasks/company_collector.go: ########## @@ -0,0 +1,76 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package tasks + +import ( + "encoding/json" + "fmt" + "github.com/apache/incubator-devlake/plugins/core" + "github.com/apache/incubator-devlake/plugins/helper" + "net/http" + "net/url" +) + +const RAW_COMPANY_TABLE = "tapd_api_companies" + +var _ core.SubTaskEntryPoint = CollectCompanies + +func CollectCompanies(taskCtx core.SubTaskContext) error { + data := taskCtx.GetData().(*TapdTaskData) + logger := taskCtx.GetLogger() + logger.Info("collect companies") + collector, err := helper.NewApiCollector(helper.ApiCollectorArgs{ + RawDataSubTaskArgs: helper.RawDataSubTaskArgs{ + Ctx: taskCtx, + Params: TapdApiParams{ + ConnectionId: data.Connection.ID, + CompanyId: data.Options.CompanyId, + }, + Table: RAW_COMPANY_TABLE, + }, + ApiClient: data.ApiClient, + //PageSize: 100, + UrlTemplate: "workspaces/projects", + Query: func(reqData *helper.RequestData) (url.Values, error) { + query := url.Values{} + query.Set("company_id", fmt.Sprintf("%v", data.Options.CompanyId)) + //query.Set("page", fmt.Sprintf("%v", reqData.Pager.Page)) + //query.Set("limit", fmt.Sprintf("%v", reqData.Pager.Size)) + return query, nil Review Comment: The two above comments should be removed -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
