ImportSprint imports csv file into the table `sprints`
(boardId string, file io.ReadCloser, incremental bool)
| 566 | |
| 567 | // ImportSprint imports csv file into the table `sprints` |
| 568 | func (s *Service) ImportSprint(boardId string, file io.ReadCloser, incremental bool) errors.Error { |
| 569 | if !incremental { |
| 570 | err := s.dal.Delete( |
| 571 | &ticket.Sprint{}, |
| 572 | dal.Where("id IN (SELECT sprint_id FROM board_sprints WHERE board_id=? AND sprint_id NOT IN (SELECT sprint_id FROM board_sprints WHERE board_id!=?))", boardId, boardId), |
| 573 | ) |
| 574 | if err != nil { |
| 575 | return err |
| 576 | } |
| 577 | err = s.dal.Delete( |
| 578 | &ticket.BoardSprint{}, |
| 579 | dal.Where("board_id = ?", boardId), |
| 580 | ) |
| 581 | if err != nil { |
| 582 | return err |
| 583 | } |
| 584 | } |
| 585 | return s.importCSV(file, boardId, s.sprintHandler(boardId)) |
| 586 | } |
| 587 | |
| 588 | // sprintHandler saves a record into the `sprints` table |
| 589 | func (s *Service) sprintHandler(boardId string) func(record map[string]interface{}) errors.Error { |