You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "d4x1 (via GitHub)" <gi...@apache.org> on 2023/10/12 10:54:33 UTC

[PR] fix(tapd): fix errors when configrating scopes [incubator-devlake]

d4x1 opened a new pull request, #6236:
URL: https://github.com/apache/incubator-devlake/pull/6236

   ### ⚠️ Pre Checklist
   
   > Please complete _ALL_ items in this checklist, and remove before submitting
   
   - [x] I have read through the [Contributing Documentation](https://devlake.apache.org/community/).
   - [x] I have added relevant tests.
   - [x] I have added relevant documentation.
   - [x] I will add labels to the PR, such as `pr-type/bug-fix`, `pr-type/feature-development`, etc.
   
   <!--
   Thanks for submitting a pull request!
   
   We appreciate you spending the time to work on these changes.
   Please fill out as many sections below as possible.
   -->
   
   ### Summary
   What does this PR do?
   TAPD's api return something like:
   ```json
   {
       "status": 1,
       "data":
       [
           {
               "Workspace":
               {
                   "id": "55850509",
                   "name": "xx",
                   "pretty_name": "55850509",
                   "description": "",
                   "status": "normal",
                   "parent_id": "1",
                   "secrecy": "0",
                   "created": "2020-11-15 16:34:28",
                   "creator_id": "1093132487",
                   "creator": "abc",
                   "begin_date": null,
                   "end_date": null,
                   "member_count": 28
               }
           }
       ],
       "info": "success"
   ```
   `id` and `parent_id` is a string which can be parsed to uint64.  Devlake's code regard these two fields as uint64.
   So I extract type `StringUint64`, adapt to TAPD's API resp.
   
   ### Does this close any open issues?
   Closes N/A
   
   ### Screenshots
   Include any relevant screenshots here.
   
   ### Other Information
   Any other information that is important to this PR.
   


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(tapd): fix errors when configrating scopes [incubator-devlake]

Posted by "d4x1 (via GitHub)" <gi...@apache.org>.
d4x1 closed pull request #6236: fix(tapd): fix errors when configrating scopes
URL: https://github.com/apache/incubator-devlake/pull/6236


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(tapd): fix errors when configrating scopes [incubator-devlake]

Posted by "d4x1 (via GitHub)" <gi...@apache.org>.
d4x1 commented on PR #6236:
URL: https://github.com/apache/incubator-devlake/pull/6236#issuecomment-1760815825

   #6239 fix this problem in a simple way.


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(tapd): fix errors when configrating scopes [incubator-devlake]

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on code in PR #6236:
URL: https://github.com/apache/incubator-devlake/pull/6236#discussion_r1357722569


##########
backend/helpers/pluginhelper/api/mapstructure.go:
##########
@@ -30,7 +30,20 @@ import (
 	"github.com/mitchellh/mapstructure"
 )
 
-func DecodeHook(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {
+var decodeHooks = []mapstructure.DecodeHookFunc{
+	decodeHookStringUint64,
+	decodeHook,
+}
+
+func decodeHookStringUint64(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {

Review Comment:
   according https://github.com/mitchellh/mapstructure/blob/main/mapstructure_examples_test.go#L123 `mapstructure` should support decoding `string` into `int`. This should not be needed, please confirm if it is necessary.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(tapd): fix errors when configrating scopes [incubator-devlake]

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on code in PR #6236:
URL: https://github.com/apache/incubator-devlake/pull/6236#discussion_r1356661226


##########
backend/plugins/tapd/models/workspace.go:
##########
@@ -42,26 +42,26 @@ type WorkspaceResponse struct {
 
 type TapdWorkspace struct {
 	common.Scope `mapstructure:",squash"`
-	Id           uint64          `gorm:"primaryKey;type:BIGINT" mapstructure:"id" json:"id"`
-	Name         string          `gorm:"type:varchar(255)" mapstructure:"name" json:"name"`
-	PrettyName   string          `gorm:"type:varchar(255)" mapstructure:"pretty_name" json:"pretty_name"`
-	Category     string          `gorm:"type:varchar(255)" mapstructure:"category" json:"category"`
-	Status       string          `gorm:"type:varchar(255)" mapstructure:"status" json:"status"`
-	Description  string          `mapstructure:"description" json:"description"`
-	BeginDate    *common.CSTTime `mapstructure:"begin_date" json:"begin_date"`
-	EndDate      *common.CSTTime `mapstructure:"end_date" json:"end_date"`
-	ExternalOn   string          `gorm:"type:varchar(255)" mapstructure:"external_on" json:"external_on"`
-	ParentId     uint64          `gorm:"type:BIGINT" mapstructure:"parent_id,string" json:"parent_id"`
-	Creator      string          `gorm:"type:varchar(255)" mapstructure:"creator" json:"creator"`
-	Created      *common.CSTTime `mapstructure:"created" json:"created"`
+	Id           *common.StringUint64 `gorm:"primaryKey;type:BIGINT" mapstructure:"id" json:"id"`

Review Comment:
   Should not be a pointer



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org