Skip to content

Commit 77f8f46

Browse files
authored
Feat support q dev dora (#8659)
* feat: add new dashboard to integrate q dev and dora * feat: support q dev with dora in infra
1 parent 3b23f29 commit 77f8f46

File tree

8 files changed

+75
-0
lines changed

8 files changed

+75
-0
lines changed

backend/plugins/q_dev/api/blueprint_v200.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func makeDataSourcePipelinePlanV200(
7171
op := &tasks.QDevOptions{
7272
ConnectionId: s3Slice.ConnectionId,
7373
S3Prefix: s3Slice.Prefix,
74+
ScopeId: s3Slice.Id,
7475
}
7576

7677
// Pass empty entities array to enable all subtasks
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package migrationscripts
19+
20+
import (
21+
"github.com/apache/incubator-devlake/core/context"
22+
"github.com/apache/incubator-devlake/core/errors"
23+
"github.com/apache/incubator-devlake/core/plugin"
24+
)
25+
26+
var _ plugin.MigrationScript = (*addScopeIdFields)(nil)
27+
28+
type addScopeIdFields struct{}
29+
30+
func (*addScopeIdFields) Up(basicRes context.BasicRes) errors.Error {
31+
db := basicRes.GetDal()
32+
33+
// Add scope_id column to _tool_q_dev_user_data table
34+
// This field links user data to QDevS3Slice scope, which can then be mapped to projects via project_mapping
35+
err := db.Exec(`
36+
ALTER TABLE _tool_q_dev_user_data
37+
ADD COLUMN IF NOT EXISTS scope_id VARCHAR(255) DEFAULT NULL
38+
`)
39+
if err != nil {
40+
// Try alternative syntax for databases that don't support IF NOT EXISTS
41+
_ = db.Exec(`ALTER TABLE _tool_q_dev_user_data ADD COLUMN scope_id VARCHAR(255) DEFAULT NULL`)
42+
}
43+
44+
// Add index on scope_id for better query performance
45+
_ = db.Exec(`CREATE INDEX IF NOT EXISTS idx_q_dev_user_data_scope_id ON _tool_q_dev_user_data(scope_id)`)
46+
47+
// Add scope_id column to _tool_q_dev_s3_file_meta table
48+
err = db.Exec(`
49+
ALTER TABLE _tool_q_dev_s3_file_meta
50+
ADD COLUMN IF NOT EXISTS scope_id VARCHAR(255) DEFAULT NULL
51+
`)
52+
if err != nil {
53+
_ = db.Exec(`ALTER TABLE _tool_q_dev_s3_file_meta ADD COLUMN scope_id VARCHAR(255) DEFAULT NULL`)
54+
}
55+
56+
// Add index on scope_id
57+
_ = db.Exec(`CREATE INDEX IF NOT EXISTS idx_q_dev_s3_file_meta_scope_id ON _tool_q_dev_s3_file_meta(scope_id)`)
58+
59+
return nil
60+
}
61+
62+
func (*addScopeIdFields) Version() uint64 {
63+
return 20251209000001
64+
}
65+
66+
func (*addScopeIdFields) Name() string {
67+
return "add scope_id field to QDevUserData and QDevS3FileMeta for project association"
68+
}

backend/plugins/q_dev/models/migrationscripts/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ func All() []plugin.MigrationScript {
3030
new(addMissingMetrics),
3131
new(addS3SliceTable),
3232
new(addScopeConfigIdToS3Slice),
33+
new(addScopeIdFields),
3334
}
3435
}

backend/plugins/q_dev/models/s3_file_meta.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type QDevS3FileMeta struct {
2929
ConnectionId uint64 `gorm:"primaryKey"`
3030
FileName string `gorm:"primaryKey;type:varchar(255)"`
3131
S3Path string `gorm:"type:varchar(512)" json:"s3Path"`
32+
ScopeId string `gorm:"type:varchar(255);index" json:"scopeId"`
3233
Processed bool `gorm:"default:false"`
3334
ProcessedTime *time.Time `gorm:"default:null"`
3435
}

backend/plugins/q_dev/models/user_data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type QDevUserData struct {
3030
UserId string `gorm:"index" json:"userId"`
3131
Date time.Time `gorm:"index" json:"date"`
3232
DisplayName string `gorm:"type:varchar(255)" json:"displayName"` // New field for user display name
33+
ScopeId string `gorm:"index;type:varchar(255)" json:"scopeId"`
3334

3435
CodeReview_FindingsCount int
3536
CodeReview_SucceededEventCount int

backend/plugins/q_dev/tasks/s3_data_extractor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func createUserDataWithDisplayName(logger interface {
161161
}, headers []string, record []string, fileMeta *models.QDevS3FileMeta, identityClient UserDisplayNameResolver) (*models.QDevUserData, errors.Error) {
162162
userData := &models.QDevUserData{
163163
ConnectionId: fileMeta.ConnectionId,
164+
ScopeId: fileMeta.ScopeId,
164165
}
165166

166167
// 创建字段映射

backend/plugins/q_dev/tasks/s3_file_collector.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func CollectQDevS3Files(taskCtx plugin.SubTaskContext) errors.Error {
8787
ConnectionId: data.Options.ConnectionId,
8888
FileName: *object.Key,
8989
S3Path: *object.Key,
90+
ScopeId: data.Options.ScopeId,
9091
Processed: false,
9192
}
9293

backend/plugins/q_dev/tasks/task_data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type QDevApiParams struct {
2828
type QDevOptions struct {
2929
ConnectionId uint64 `json:"connectionId"`
3030
S3Prefix string `json:"s3Prefix"`
31+
ScopeId string `json:"scopeId"`
3132
}
3233

3334
type QDevTaskData struct {

0 commit comments

Comments
 (0)