commit eb9984c0b3bb4279d020741041a7d959efcdc048
parent 2227fed46032b4d0fb201b6e629a6873a92247de
Author: Wim Dupont <wim@wimdupont.com>
Date: Fri, 17 Feb 2023 03:39:00 +0100
search guides based on hash
Former-commit-id: 97a97040135a687a75cda4b99776315d54df1d4f
Diffstat:
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/wimdupont/personalweb/repository/GuideRepository.java b/src/main/java/com/wimdupont/personalweb/repository/GuideRepository.java
@@ -13,7 +13,7 @@ import java.util.Optional;
public interface GuideRepository extends JpaRepository<Guide, String> {
Optional<Guide> findByPath(String path);
-
+ Optional<Guide> findByContentSha256(String contentSha256);
//Native to exclude columns
@Query(value = "select path from guide order by created_date desc", nativeQuery = true)
List<GuideMeta> findAllMetaData();
diff --git a/src/main/java/com/wimdupont/personalweb/service/GuideService.java b/src/main/java/com/wimdupont/personalweb/service/GuideService.java
@@ -44,9 +44,7 @@ public class GuideService {
var guidesToGenerate = new ArrayList<Guide>();
gitlabApi.getRepositoryTree().orElseThrow()
.forEach(repositoryTreeItem -> gitlabApi.getRepositoryFile(repositoryTreeItem.path())
- .filter(repositoryFile -> findByPath(repositoryFile.path())
- .map(guide -> guide.getContentSha256().equals(repositoryFile.contentSha256()))
- .isEmpty())
+ .filter(repositoryFile -> guideRepository.findByContentSha256(repositoryFile.contentSha256()).isEmpty())
.map(repositoryFile -> Guide.Builder.newBuilder()
.contentSha256(repositoryFile.contentSha256())
.contentBase64(repositoryFile.contentBase64())