• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loveapple / web-crawler / 36

10 Jul 2025 11:46AM UTC coverage: 49.231% (-47.6%) from 96.875%
36

push

circleci

Chunli Hao
coding bulkInsert

1 of 33 new or added lines in 2 files covered. (3.03%)

32 of 65 relevant lines covered (49.23%)

0.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.33
/src/main/java/com/happinesea/webcrawler/service/SiteContentsService.java
1
package com.happinesea.webcrawler.service;
2

3
import java.util.List;
4

5
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.stereotype.Service;
7

8
import com.happinesea.webcrawler.entity.SiteContents;
9
import com.happinesea.webcrawler.repository.SiteContentsRepository;
10

11
import jakarta.transaction.Transactional;
12

13
@Service
14
public class SiteContentsService {
1✔
15
        @Autowired
16
    private SiteContentsRepository repository;
17
        
18
        /**
19
     * 重複しないデータだけを一括保存
20
     */
21
    @Transactional
22
    public void bulkInsertIfNotExists(List<SiteContents> newContents) {
23
        // 1. URLリスト抽出
NEW
24
        List<String> urls = newContents.stream()
×
NEW
25
                .map(SiteContents::getUrl)
×
NEW
26
                .toList();
×
27

28
        // 2. 既存データ取得
NEW
29
        List<String> existingUrls = repository.findAllByUrlIn(urls).stream()
×
NEW
30
                .map(SiteContents::getUrl)
×
NEW
31
                .toList();
×
32

33
        // 3. 差分だけ抽出
NEW
34
        List<SiteContents> filtered = newContents.stream()
×
NEW
35
                .filter(c -> !existingUrls.contains(c.getUrl()))
×
NEW
36
                .toList();
×
37

38
        // 4. 一括保存 (saveAll → バルク insert)
NEW
39
        repository.saveAll(filtered);
×
NEW
40
    }
×
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc