Improvements, Fixes.

This commit is contained in:
Stefan Hardegger
2025-08-18 10:04:38 +02:00
parent 95ce5fb532
commit 40fe3fdb80
13 changed files with 13 additions and 23 deletions

View File

@@ -4,7 +4,6 @@ import com.storycove.entity.Author;
import org.springframework.data.domain.Page;
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;
import org.springframework.stereotype.Repository;

View File

@@ -2,7 +2,6 @@ package com.storycove.repository;
import com.storycove.entity.Collection;
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;
import org.springframework.stereotype.Repository;

View File

@@ -7,7 +7,6 @@ import com.storycove.entity.Tag;
import org.springframework.data.domain.Page;
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;
import org.springframework.stereotype.Repository;

View File

@@ -242,7 +242,7 @@ public class AuthorService {
rating, author.getName(), author.getAuthorRating());
author.setAuthorRating(rating);
Author savedAuthor = authorRepository.save(author);
authorRepository.save(author);
// Flush and refresh to ensure the entity is up-to-date
authorRepository.flush();

View File

@@ -11,14 +11,10 @@ import com.storycove.repository.CollectionRepository;
import com.storycove.repository.CollectionStoryRepository;
import com.storycove.repository.StoryRepository;
import com.storycove.repository.TagRepository;
import com.storycove.service.exception.DuplicateResourceException;
import com.storycove.service.exception.ResourceNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -266,7 +262,7 @@ public class CollectionService {
*/
@Transactional
public void reorderStories(UUID collectionId, List<Map<String, Object>> storyOrders) {
Collection collection = findByIdBasic(collectionId);
findByIdBasic(collectionId); // Validate collection exists
// Two-phase update to avoid unique constraint violations:
// Phase 1: Set all positions to negative values (temporary)

View File

@@ -1,7 +1,6 @@
package com.storycove.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.storycove.entity.*;
import com.storycove.repository.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -587,6 +586,7 @@ public class DatabaseManagementService {
// Validate metadata
try {
ObjectMapper mapper = new ObjectMapper();
@SuppressWarnings("unchecked")
Map<String, Object> metadata = mapper.readValue(Files.newInputStream(metadataFile), Map.class);
String format = (String) metadata.get("format");

View File

@@ -21,7 +21,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

View File

@@ -26,8 +26,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
@Service
@Transactional

View File

@@ -13,7 +13,6 @@ import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -124,7 +123,7 @@ public class StoryService {
@Transactional(readOnly = true)
public List<Story> findBySeries(UUID seriesId) {
Series series = seriesService.findById(seriesId);
seriesService.findById(seriesId); // Validate series exists
return storyRepository.findBySeriesOrderByVolume(seriesId);
}

View File

@@ -247,7 +247,7 @@ public class TagService {
}
public void removeAlias(UUID tagId, UUID aliasId) {
Tag canonicalTag = findById(tagId);
findById(tagId); // Validate tag exists
TagAlias alias = tagAliasRepository.findById(aliasId)
.orElseThrow(() -> new ResourceNotFoundException("Tag alias", aliasId.toString()));

View File

@@ -958,8 +958,9 @@ public class TypesenseService {
// Try to get collection info for debugging
try {
CollectionResponse collection = typesenseClient.collections(AUTHORS_COLLECTION).retrieve();
typesenseClient.collections(AUTHORS_COLLECTION).retrieve();
} catch (Exception debugException) {
// Debug collection retrieval failed
}
// Use wildcard approach for fallback to handle substring search