MCPcopy Index your code
hub / github.com/apache/devlake / ImportIssue

Method ImportIssue

backend/plugins/customize/service/service.go:158–186  ·  view source on GitHub ↗

ImportIssue import csv file to the table `issues`, and create relations to boards issue could exist in multiple boards, so we should only delete an old records when it doesn't belong to another board

(boardId string, file io.ReadCloser, incremental bool)

Source from the content-addressed store, hash-verified

156// ImportIssue import csv file to the table `issues`, and create relations to boards
157// issue could exist in multiple boards, so we should only delete an old records when it doesn't belong to another board
158func (s *Service) ImportIssue(boardId string, file io.ReadCloser, incremental bool) errors.Error {
159 if !incremental {
160 // not delete accounts data since account may be referenced by others
161 err := s.dal.Delete(
162 &ticket.Issue{},
163 dal.Where("id IN (SELECT issue_id FROM board_issues WHERE board_id=? AND issue_id NOT IN (SELECT issue_id FROM board_issues WHERE board_id!=?))", boardId, boardId),
164 )
165 if err != nil {
166 return err
167 }
168
169 err = s.dal.Delete(
170 &ticket.IssueLabel{},
171 dal.Where("issue_id IN (SELECT issue_id FROM board_issues WHERE board_id=? AND issue_id NOT IN (SELECT issue_id FROM board_issues WHERE board_id!=?))", boardId, boardId),
172 )
173 if err != nil {
174 return err
175 }
176
177 err = s.dal.Delete(
178 &ticket.BoardIssue{},
179 dal.Where("board_id = ?", boardId),
180 )
181 if err != nil {
182 return err
183 }
184 }
185 return s.importCSV(file, boardId, s.issueHandlerFactory(boardId, incremental))
186}
187
188// SaveBoard make sure the board exists in table `boards`
189func (s *Service) SaveBoard(boardId, boardName string) errors.Error {

Callers 1

TestImportIssueDataFlowFunction · 0.95

Calls 3

importCSVMethod · 0.95
issueHandlerFactoryMethod · 0.95
DeleteMethod · 0.65

Tested by 1

TestImportIssueDataFlowFunction · 0.76