package gc.mda.kcg.domain.osint;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.Instant;
import java.util.List;

@Service
@RequiredArgsConstructor
public class OsintService {

    private final OsintFeedRepository repository;

    /**
     * 시간 범위 내 OSINT 피드를 조회하여 반환.
     * focus(region) 필드 기준 필터링, publishedAt 기준 정렬.
     */
    public List<OsintDto> getByDateRange(String region, Instant from, Instant to) {
        return repository.findByRegionAndPublishedAtBetweenOrderByPublishedAtDesc(region, from, to)
                .stream()
                .map(OsintDto::from)
                .toList();
    }
}
