abeizn commented on code in PR #6143:
URL:
https://github.com/apache/incubator-devlake/pull/6143#discussion_r1335654432
##########
backend/core/models/common/base.go:
##########
@@ -85,10 +79,31 @@ func NewNoPKModel() NoPKModel {
}
}
-var (
- DUPLICATE_REGEX = regexp.MustCompile(`(?i)\bduplicate\b`)
-)
+type Scope struct {
+ NoPKModel `json:"-" mapstructure:"-"`
+ ConnectionId uint64 `json:"connectionId" gorm:"primaryKey"
validate:"required" mapstructure:"connectionId,omitempty"`
+ ScopeConfigId uint64 `json:"scopeConfigId,omitempty"
mapstructure:"scopeConfigId,omitempty"`
+}
-func IsDuplicateError(err error) bool {
- return err != nil && DUPLICATE_REGEX.MatchString(err.Error())
+// ScopeConnectionId implements plugin.ToolLayerScope.
+func (s Scope) ScopeConnectionId() uint64 {
+ return s.ConnectionId
+}
+
+func (s Scope) ScopeScopeConfigId() uint64 {
+ return s.ScopeConfigId
+}
+
+type ScopeConfig struct {
+ Model
+ Entities []string `gorm:"type:json;serializer:json" json:"entities"
mapstructure:"entities"`
+ ConnectionId uint64 `json:"connectionId" gorm:"index"
validate:"required" mapstructure:"connectionId,omitempty"`
+ Name string `mapstructure:"name" json:"name"
gorm:"type:varchar(255);index:idx_name_github,unique" validate:"required"`
Review Comment:
Is this(idx_name_github) a suitable name?
##########
backend/core/models/common/base.go:
##########
@@ -85,10 +79,31 @@ func NewNoPKModel() NoPKModel {
}
}
-var (
- DUPLICATE_REGEX = regexp.MustCompile(`(?i)\bduplicate\b`)
-)
+type Scope struct {
+ NoPKModel `json:"-" mapstructure:"-"`
+ ConnectionId uint64 `json:"connectionId" gorm:"primaryKey"
validate:"required" mapstructure:"connectionId,omitempty"`
+ ScopeConfigId uint64 `json:"scopeConfigId,omitempty"
mapstructure:"scopeConfigId,omitempty"`
+}
-func IsDuplicateError(err error) bool {
- return err != nil && DUPLICATE_REGEX.MatchString(err.Error())
+// ScopeConnectionId implements plugin.ToolLayerScope.
+func (s Scope) ScopeConnectionId() uint64 {
+ return s.ConnectionId
+}
+
+func (s Scope) ScopeScopeConfigId() uint64 {
+ return s.ScopeConfigId
+}
+
+type ScopeConfig struct {
+ Model
+ Entities []string `gorm:"type:json;serializer:json" json:"entities"
mapstructure:"entities"`
+ ConnectionId uint64 `json:"connectionId" gorm:"index"
validate:"required" mapstructure:"connectionId,omitempty"`
+ Name string `mapstructure:"name" json:"name"
gorm:"type:varchar(255);index:idx_name_github,unique" validate:"required"`
Review Comment:
Is this(idx_name_github) a suitable name?
--
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]