This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch release-v0.11-hotfix
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.11-hotfix by this 
push:
     new 4be2024d fix: convert story point to signed integer
4be2024d is described below

commit 4be2024ddcc5bdee987ef906286ab7ac9a732172
Author: zhangliang <[email protected]>
AuthorDate: Thu Jun 30 20:07:08 2022 +0800

    fix: convert story point to signed integer
---
 .github/workflows/build.yml                        | 35 ++++++-------
 models/domainlayer/ticket/issue.go                 |  2 +-
 models/migrationscripts/register.go                |  1 +
 models/migrationscripts/updateSchemas20220630.go   | 60 ++++++++++++++++++++++
 plugins/jira/jira.go                               |  1 +
 plugins/jira/models/issue.go                       |  2 +-
 .../migrationscripts/updateSchemas20220630.go      | 60 ++++++++++++++++++++++
 plugins/jira/tasks/issue_extractor.go              |  2 +-
 plugins/tapd/tasks/story_converter.go              |  2 +-
 9 files changed, 143 insertions(+), 22 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 51997a99..0c19985e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -3,6 +3,8 @@ env:
   IMAGE_LAKE: ${{ secrets.DOCKERHUB_OWNER }}/devlake
   IMAGE_CONFIG_UI: ${{ secrets.DOCKERHUB_OWNER }}/devlake-config-ui
   IMAGE_GRAFANA: ${{ secrets.DOCKERHUB_OWNER }}/devlake-dashboard
+  DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USER }}
+  DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
 on:
   push:
     tags:
@@ -23,17 +25,16 @@ jobs:
       - name: Login to DockerHub
         uses: docker/login-action@v2
         with:
-          username: ${{ secrets.DOCKERHUB_USERNAME }}
-          password: ${{ secrets.DOCKERHUB_TOKEN }}
+          username: ${{ env.DOCKERHUB_USERNAME }}
+          password: ${{ env.DOCKERHUB_TOKEN }}
       - name: Build lake image
         run: |
           docker build -t ${{ env.IMAGE_LAKE }}:latest --file ./Dockerfile .
           docker tag ${{ env.IMAGE_LAKE }}:latest ${{ env.IMAGE_LAKE }}:${{ 
github.ref_name }}
           docker push ${{ env.IMAGE_LAKE }}:${{ github.ref_name }}
-      - name: Push latest
-        if: ${{ !contains( github.ref_name, 'rc') && !contains( 
github.ref_name, 'test')}}
-        run: |
-          docker push ${{ env.IMAGE_LAKE }}:latest
+          if printf {{ github.ref_name }} | grep -Pq '^v(\d+).(\d+).(\d+)$'; 
then
+            docker push ${{ env.IMAGE_LAKE }}:latest
+          fi
   build-configui:
     name: Build config-ui image
     runs-on: ubuntu-20.04
@@ -48,18 +49,17 @@ jobs:
       - name: Login to DockerHub
         uses: docker/login-action@v2
         with:
-          username: ${{ secrets.DOCKERHUB_USERNAME }}
-          password: ${{ secrets.DOCKERHUB_TOKEN }}
+          username: ${{ env.DOCKERHUB_USERNAME }}
+          password: ${{ env.DOCKERHUB_TOKEN }}
       - name: Build config ui image
         run: |
           cd config-ui
           docker build -t ${{ env.IMAGE_CONFIG_UI }}:latest --file 
./Dockerfile .
           docker tag ${{ env.IMAGE_CONFIG_UI }}:latest ${{ env.IMAGE_CONFIG_UI 
}}:${{ github.ref_name }}
           docker push ${{ env.IMAGE_CONFIG_UI }}:${{ github.ref_name }}
-      - name: Push latest
-        if: ${{ !contains( github.ref_name, 'rc') && !contains( 
github.ref_name, 'test')}}
-        run: |
-          docker push ${{ env.IMAGE_CONFIG_UI }}:latest
+          if printf {{ github.ref_name }} | grep -Pq '^v(\d+).(\d+).(\d+)$'; 
then
+            docker push ${{ env.IMAGE_CONFIG_UI }}:latest
+          fi
   build-grafana:
     name: Build grafana image
     runs-on: ubuntu-20.04
@@ -74,15 +74,14 @@ jobs:
       - name: Login to DockerHub
         uses: docker/login-action@v2
         with:
-          username: ${{ secrets.DOCKERHUB_USERNAME }}
-          password: ${{ secrets.DOCKERHUB_TOKEN }}
+          username: ${{ env.DOCKERHUB_USERNAME }}
+          password: ${{ env.DOCKERHUB_TOKEN }}
       - name: Build grafana
         run: |
           cd grafana
           docker build -t ${{ env.IMAGE_GRAFANA }}:latest --file ./Dockerfile .
           docker tag ${{ env.IMAGE_GRAFANA }}:latest ${{ env.IMAGE_GRAFANA 
}}:${{ github.ref_name }}
           docker push ${{ env.IMAGE_GRAFANA }}:${{ github.ref_name }}
-      - name: Push latest
-        if: ${{ !contains( github.ref_name, 'rc') && !contains( 
github.ref_name, 'test')}}
-        run: |
-          docker push ${{ env.IMAGE_DASHBOARD }}:latest
\ No newline at end of file
+          if printf {{ github.ref_name }} | grep -Pq '^v(\d+).(\d+).(\d+)$'; 
then
+            docker push ${{ env.IMAGE_DASHBOARD }}:latest
+          fi
diff --git a/models/domainlayer/ticket/issue.go 
b/models/domainlayer/ticket/issue.go
index ce391698..4742d295 100644
--- a/models/domainlayer/ticket/issue.go
+++ b/models/domainlayer/ticket/issue.go
@@ -34,7 +34,7 @@ type Issue struct {
        Type                    string `gorm:"type:varchar(100)"`
        Status                  string `gorm:"type:varchar(100)"`
        OriginalStatus          string `gorm:"type:varchar(100)"`
-       StoryPoint              uint
+       StoryPoint              int64
        ResolutionDate          *time.Time
        CreatedDate             *time.Time
        UpdatedDate             *time.Time
diff --git a/models/migrationscripts/register.go 
b/models/migrationscripts/register.go
index ad45e755..d45d821a 100644
--- a/models/migrationscripts/register.go
+++ b/models/migrationscripts/register.go
@@ -27,5 +27,6 @@ func RegisterAll() {
                new(updateSchemas20220513), new(updateSchemas20220524), 
new(updateSchemas20220526),
                new(updateSchemas20220527), new(updateSchemas20220528), 
new(updateSchemas20220602),
                new(updateSchemas2022061402),
+               new(UpdateSchemas20220630),
        }, "Framework")
 }
diff --git a/models/migrationscripts/updateSchemas20220630.go 
b/models/migrationscripts/updateSchemas20220630.go
new file mode 100644
index 00000000..5d641e8c
--- /dev/null
+++ b/models/migrationscripts/updateSchemas20220630.go
@@ -0,0 +1,60 @@
+/*
+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 migrationscripts
+
+import (
+       "context"
+
+       "gorm.io/gorm"
+)
+
+type Issue20220630 struct {
+       StoryPoint    int64
+       TmpStoryPoint uint
+}
+
+func (Issue20220630) TableName() string {
+       return "issues"
+}
+
+type UpdateSchemas20220630 struct {
+}
+
+func (u *UpdateSchemas20220630) Up(ctx context.Context, db *gorm.DB) error {
+       err := db.Migrator().RenameColumn(&Issue20220630{}, "story_point", 
"tmp_story_point")
+       if err != nil {
+               return err
+       }
+       err = db.Migrator().AddColumn(&Issue20220630{}, "story_point")
+       if err != nil {
+               return err
+       }
+       err = db.Model(&Issue20220630{}).Where("1 = 
1").UpdateColumn("story_point", gorm.Expr("tmp_story_point")).Error
+       if err != nil {
+               return err
+       }
+       return db.Migrator().DropColumn(&Issue20220630{}, "tmp_story_point")
+}
+
+func (*UpdateSchemas20220630) Version() uint64 {
+       return 20220630131508
+}
+
+func (*UpdateSchemas20220630) Name() string {
+       return "alter story_point from unsigned to signed"
+}
diff --git a/plugins/jira/jira.go b/plugins/jira/jira.go
index 5c10467a..e47ef1fb 100644
--- a/plugins/jira/jira.go
+++ b/plugins/jira/jira.go
@@ -158,6 +158,7 @@ func (plugin Jira) MigrationScripts() []migration.Script {
                new(migrationscripts.UpdateSchemas20220527),
                new(migrationscripts.UpdateSchemas20220614),
                new(migrationscripts.UpdateSchemas20220616),
+               new(migrationscripts.UpdateSchemas20220630),
        }
 }
 
diff --git a/plugins/jira/models/issue.go b/plugins/jira/models/issue.go
index a727099b..9d3be492 100644
--- a/plugins/jira/models/issue.go
+++ b/plugins/jira/models/issue.go
@@ -58,7 +58,7 @@ type JiraIssue struct {
        Updated                  time.Time `gorm:"index"`
        SpentMinutes             int64
        LeadTimeMinutes          uint
-       StdStoryPoint            uint
+       StdStoryPoint            int64
        StdType                  string `gorm:"type:varchar(255)"`
        StdStatus                string `gorm:"type:varchar(255)"`
        AllFields                datatypes.JSONMap
diff --git a/plugins/jira/models/migrationscripts/updateSchemas20220630.go 
b/plugins/jira/models/migrationscripts/updateSchemas20220630.go
new file mode 100644
index 00000000..5e9132d1
--- /dev/null
+++ b/plugins/jira/models/migrationscripts/updateSchemas20220630.go
@@ -0,0 +1,60 @@
+/*
+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 migrationscripts
+
+import (
+       "context"
+
+       "gorm.io/gorm"
+)
+
+type JiraIssue20220630 struct {
+       StdStoryPoint    int64
+       TmpStdStoryPoint uint
+}
+
+func (JiraIssue20220630) TableName() string {
+       return "_tool_jira_issues"
+}
+
+type UpdateSchemas20220630 struct {
+}
+
+func (u *UpdateSchemas20220630) Up(ctx context.Context, db *gorm.DB) error {
+       err := db.Migrator().RenameColumn(&JiraIssue20220630{}, 
"std_story_point", "tmp_std_story_point")
+       if err != nil {
+               return err
+       }
+       err = db.Migrator().AddColumn(&JiraIssue20220630{}, "std_story_point")
+       if err != nil {
+               return err
+       }
+       err = db.Model(&JiraIssue20220630{}).Where("1 = 
1").UpdateColumn("std_story_point", gorm.Expr("tmp_std_story_point")).Error
+       if err != nil {
+               return err
+       }
+       return db.Migrator().DropColumn(&JiraIssue20220630{}, 
"tmp_std_story_point")
+}
+
+func (*UpdateSchemas20220630) Version() uint64 {
+       return 20220630130656
+}
+
+func (*UpdateSchemas20220630) Name() string {
+       return "alter std_story_point from unsigned to signed"
+}
diff --git a/plugins/jira/tasks/issue_extractor.go 
b/plugins/jira/tasks/issue_extractor.go
index c4e9cca5..73126d08 100644
--- a/plugins/jira/tasks/issue_extractor.go
+++ b/plugins/jira/tasks/issue_extractor.go
@@ -111,7 +111,7 @@ func ExtractIssues(taskCtx core.SubTaskContext) error {
                        if issue.ResolutionDate != nil {
                                issue.LeadTimeMinutes = 
uint(issue.ResolutionDate.Unix()-issue.Created.Unix()) / 60
                        }
-                       issue.StdStoryPoint = uint(issue.StoryPoint)
+                       issue.StdStoryPoint = int64(issue.StoryPoint)
                        issue.StdType = getStdType(issue.Type)
                        issue.StdStatus = GetStdStatus(issue.StatusKey)
                        if len(changelogs) < 100 {
diff --git a/plugins/tapd/tasks/story_converter.go 
b/plugins/tapd/tasks/story_converter.go
index 1fc1e147..2950f139 100644
--- a/plugins/tapd/tasks/story_converter.go
+++ b/plugins/tapd/tasks/story_converter.go
@@ -62,7 +62,7 @@ func ConvertStory(taskCtx core.SubTaskContext) error {
                                Title:                toolL.Name,
                                Type:                 toolL.StdType,
                                Status:               toolL.StdStatus,
-                               StoryPoint:           uint(toolL.Size),
+                               StoryPoint:           int64(toolL.Size),
                                OriginalStatus:       toolL.Status,
                                ResolutionDate:       
(*time.Time)(&toolL.Completed),
                                CreatedDate:          
(*time.Time)(&toolL.Created),

Reply via email to