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

lynwee pushed a commit to branch fix-8330
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/fix-8330 by this push:
     new cfa9f36e0 fix(jira): remove outdated records when convertor is not in 
incremental mode
cfa9f36e0 is described below

commit cfa9f36e0e5137e35d6b870f61a73e00e3fff0b1
Author: d4x1 <[email protected]>
AuthorDate: Wed Mar 12 18:37:48 2025 +0800

    fix(jira): remove outdated records when convertor is not in incremental mode
---
 backend/plugins/jira/tasks/issue_convertor.go | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/backend/plugins/jira/tasks/issue_convertor.go 
b/backend/plugins/jira/tasks/issue_convertor.go
index d5591c138..8a329ddf7 100644
--- a/backend/plugins/jira/tasks/issue_convertor.go
+++ b/backend/plugins/jira/tasks/issue_convertor.go
@@ -41,6 +41,7 @@ var ConvertIssuesMeta = plugin.SubTaskMeta{
 }
 
 func ConvertIssues(subtaskCtx plugin.SubTaskContext) errors.Error {
+       logger := subtaskCtx.GetLogger()
        data := subtaskCtx.GetData().(*JiraTaskData)
        db := subtaskCtx.GetDal()
        mappings, err := getTypeMappings(data, db)
@@ -163,6 +164,26 @@ func ConvertIssues(subtaskCtx plugin.SubTaskContext) 
errors.Error {
                return err
        }
 
+       if !converter.IsIncremental() {
+               logger.Debug("deleting outdated records for board_issues, 
issue_assignees and issues")
+               dalWhere := dal.Where("_raw_data_table in ? AND 
_raw_data_params = ?",
+                       []string{"_raw_jira_api_issues", "_raw_jira_api_epics"},
+                       converter.GetRawDataParams(),
+               )
+               if err := db.Delete(ticket.Issue{}, dalWhere); err != nil {
+                       logger.Error(err, "delete issues")
+                       return err
+               }
+               if err := db.Delete(ticket.IssueAssignee{}, dalWhere); err != 
nil {
+                       logger.Error(err, "delete issue_assignees")
+                       return err
+               }
+               if err := db.Delete(ticket.BoardIssue{}, dalWhere); err != nil {
+                       logger.Error(err, "delete board_issues")
+                       return err
+               }
+       }
+
        return converter.Execute()
 }
 

Reply via email to