Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

feat: change delete of quicktest-archive to custom query #248

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import javax.transaction.Transactional;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface QuickTestArchiveRepository extends JpaRepository<QuickTestArchive, String> {

Expand All @@ -48,4 +52,9 @@ List<QuickTestArchiveView> findAllByTenantIdAndPocIdAndTestResultInAndUpdatedAtB
);

Stream<QuickTestArchiveDataView> findAllByUpdatedAtBefore(LocalDateTime updatedAt, Pageable pageable);

@Transactional
@Modifying
@Query("DELETE FROM QuickTestArchive q WHERE q.hashedGuid = :hashedGuid")
int deleteByHashedGuid(@Param("hashedGuid") String hashedGuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void moveToArchive() {
.map(this::buildArchive)
.map(repository::save)
.map(Archive::getHashedGuid)
.forEach(quickTestArchiveRepository::deleteById);
.forEach(quickTestArchiveRepository::deleteByHashedGuid);
} else {
log.error("Property 'archive.moveToArchiveJob.older-than-in-seconds' not set.");
}
Expand Down