fix(#240): remove readyCount from weekly stats DTO and SQL query
The Lesefertig pulse was removed from the UI; drop the backend support for it too — removes the subquery from findWeeklyStats(), the projection getter, the DTO field, and updates all affected tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,5 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
*/
|
*/
|
||||||
public record TranscriptionWeeklyStatsDTO(
|
public record TranscriptionWeeklyStatsDTO(
|
||||||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) long segmentationCount,
|
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) long segmentationCount,
|
||||||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) long transcriptionCount,
|
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) long transcriptionCount
|
||||||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) long readyCount
|
|
||||||
) {}
|
) {}
|
||||||
|
|||||||
@@ -232,10 +232,7 @@ public interface DocumentRepository extends JpaRepository<Document, UUID>, JpaSp
|
|||||||
WHERE da.created_at >= NOW() - INTERVAL '7 days') AS segmentationCount,
|
WHERE da.created_at >= NOW() - INTERVAL '7 days') AS segmentationCount,
|
||||||
(SELECT COUNT(DISTINCT tb.document_id) FROM transcription_blocks tb
|
(SELECT COUNT(DISTINCT tb.document_id) FROM transcription_blocks tb
|
||||||
WHERE tb.created_at >= NOW() - INTERVAL '7 days'
|
WHERE tb.created_at >= NOW() - INTERVAL '7 days'
|
||||||
AND tb.text IS NOT NULL AND tb.text <> '') AS transcriptionCount,
|
AND tb.text IS NOT NULL AND tb.text <> '') AS transcriptionCount
|
||||||
(SELECT COUNT(DISTINCT tb.document_id) FROM transcription_blocks tb
|
|
||||||
WHERE tb.updated_at >= NOW() - INTERVAL '7 days'
|
|
||||||
AND tb.reviewed = true) AS readyCount
|
|
||||||
""")
|
""")
|
||||||
TranscriptionWeeklyStatsProjection findWeeklyStats();
|
TranscriptionWeeklyStatsProjection findWeeklyStats();
|
||||||
|
|
||||||
|
|||||||
@@ -7,5 +7,4 @@ package org.raddatz.familienarchiv.repository;
|
|||||||
public interface TranscriptionWeeklyStatsProjection {
|
public interface TranscriptionWeeklyStatsProjection {
|
||||||
long getSegmentationCount();
|
long getSegmentationCount();
|
||||||
long getTranscriptionCount();
|
long getTranscriptionCount();
|
||||||
long getReadyCount();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,7 @@ public class TranscriptionQueueService {
|
|||||||
var stats = documentRepository.findWeeklyStats();
|
var stats = documentRepository.findWeeklyStats();
|
||||||
return new TranscriptionWeeklyStatsDTO(
|
return new TranscriptionWeeklyStatsDTO(
|
||||||
stats.getSegmentationCount(),
|
stats.getSegmentationCount(),
|
||||||
stats.getTranscriptionCount(),
|
stats.getTranscriptionCount()
|
||||||
stats.getReadyCount()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class TranscriptionQueueControllerTest {
|
|||||||
3, 1, 0
|
3, 1, 0
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final TranscriptionWeeklyStatsDTO STATS = new TranscriptionWeeklyStatsDTO(2L, 5L, 1L);
|
private static final TranscriptionWeeklyStatsDTO STATS = new TranscriptionWeeklyStatsDTO(2L, 5L);
|
||||||
|
|
||||||
// ─── segmentation-queue ───────────────────────────────────────────────────
|
// ─── segmentation-queue ───────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -145,7 +145,6 @@ class TranscriptionQueueControllerTest {
|
|||||||
mockMvc.perform(get("/api/transcription/weekly-stats"))
|
mockMvc.perform(get("/api/transcription/weekly-stats"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.segmentationCount").value(2))
|
.andExpect(jsonPath("$.segmentationCount").value(2))
|
||||||
.andExpect(jsonPath("$.transcriptionCount").value(5))
|
.andExpect(jsonPath("$.transcriptionCount").value(5));
|
||||||
.andExpect(jsonPath("$.readyCount").value(1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,7 +343,6 @@ class DocumentRepositoryTest {
|
|||||||
|
|
||||||
assertThat(stats.getSegmentationCount()).isEqualTo(0L);
|
assertThat(stats.getSegmentationCount()).isEqualTo(0L);
|
||||||
assertThat(stats.getTranscriptionCount()).isEqualTo(0L);
|
assertThat(stats.getTranscriptionCount()).isEqualTo(0L);
|
||||||
assertThat(stats.getReadyCount()).isEqualTo(0L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── seeding helpers ─────────────────────────────────────────────────────
|
// ─── seeding helpers ─────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -88,26 +88,24 @@ class TranscriptionQueueServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getWeeklyStats_mapsProjectionToDTO() {
|
void getWeeklyStats_mapsProjectionToDTO() {
|
||||||
TranscriptionWeeklyStatsProjection proj = mockStatsProjection(3L, 7L, 2L);
|
TranscriptionWeeklyStatsProjection proj = mockStatsProjection(3L, 7L);
|
||||||
when(documentRepository.findWeeklyStats()).thenReturn(proj);
|
when(documentRepository.findWeeklyStats()).thenReturn(proj);
|
||||||
|
|
||||||
TranscriptionWeeklyStatsDTO result = service.getWeeklyStats();
|
TranscriptionWeeklyStatsDTO result = service.getWeeklyStats();
|
||||||
|
|
||||||
assertThat(result.segmentationCount()).isEqualTo(3L);
|
assertThat(result.segmentationCount()).isEqualTo(3L);
|
||||||
assertThat(result.transcriptionCount()).isEqualTo(7L);
|
assertThat(result.transcriptionCount()).isEqualTo(7L);
|
||||||
assertThat(result.readyCount()).isEqualTo(2L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getWeeklyStats_returnsZeros_whenAllCountsAreZero() {
|
void getWeeklyStats_returnsZeros_whenAllCountsAreZero() {
|
||||||
TranscriptionWeeklyStatsProjection proj = mockStatsProjection(0L, 0L, 0L);
|
TranscriptionWeeklyStatsProjection proj = mockStatsProjection(0L, 0L);
|
||||||
when(documentRepository.findWeeklyStats()).thenReturn(proj);
|
when(documentRepository.findWeeklyStats()).thenReturn(proj);
|
||||||
|
|
||||||
TranscriptionWeeklyStatsDTO result = service.getWeeklyStats();
|
TranscriptionWeeklyStatsDTO result = service.getWeeklyStats();
|
||||||
|
|
||||||
assertThat(result.segmentationCount()).isEqualTo(0L);
|
assertThat(result.segmentationCount()).isEqualTo(0L);
|
||||||
assertThat(result.transcriptionCount()).isEqualTo(0L);
|
assertThat(result.transcriptionCount()).isEqualTo(0L);
|
||||||
assertThat(result.readyCount()).isEqualTo(0L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── helpers ─────────────────────────────────────────────────────────────
|
// ─── helpers ─────────────────────────────────────────────────────────────
|
||||||
@@ -126,11 +124,10 @@ class TranscriptionQueueServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TranscriptionWeeklyStatsProjection mockStatsProjection(
|
private TranscriptionWeeklyStatsProjection mockStatsProjection(
|
||||||
long segmentationCount, long transcriptionCount, long readyCount) {
|
long segmentationCount, long transcriptionCount) {
|
||||||
TranscriptionWeeklyStatsProjection proj = mock(TranscriptionWeeklyStatsProjection.class);
|
TranscriptionWeeklyStatsProjection proj = mock(TranscriptionWeeklyStatsProjection.class);
|
||||||
when(proj.getSegmentationCount()).thenReturn(segmentationCount);
|
when(proj.getSegmentationCount()).thenReturn(segmentationCount);
|
||||||
when(proj.getTranscriptionCount()).thenReturn(transcriptionCount);
|
when(proj.getTranscriptionCount()).thenReturn(transcriptionCount);
|
||||||
when(proj.getReadyCount()).thenReturn(readyCount);
|
|
||||||
return proj;
|
return proj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1519,8 +1519,6 @@ export interface components {
|
|||||||
segmentationCount: number;
|
segmentationCount: number;
|
||||||
/** Format: int64 */
|
/** Format: int64 */
|
||||||
transcriptionCount: number;
|
transcriptionCount: number;
|
||||||
/** Format: int64 */
|
|
||||||
readyCount: number;
|
|
||||||
};
|
};
|
||||||
TranscriptionQueueItemDTO: {
|
TranscriptionQueueItemDTO: {
|
||||||
/** Format: uuid */
|
/** Format: uuid */
|
||||||
@@ -1548,14 +1546,14 @@ export interface components {
|
|||||||
displayName?: string;
|
displayName?: string;
|
||||||
firstName?: string;
|
firstName?: string;
|
||||||
lastName?: string;
|
lastName?: string;
|
||||||
/** Format: int64 */
|
|
||||||
documentCount?: number;
|
|
||||||
/** Format: int32 */
|
/** Format: int32 */
|
||||||
birthYear?: number;
|
birthYear?: number;
|
||||||
/** Format: int32 */
|
/** Format: int32 */
|
||||||
deathYear?: number;
|
deathYear?: number;
|
||||||
alias?: string;
|
alias?: string;
|
||||||
notes?: string;
|
notes?: string;
|
||||||
|
/** Format: int64 */
|
||||||
|
documentCount?: number;
|
||||||
personType?: string;
|
personType?: string;
|
||||||
};
|
};
|
||||||
TrainingInfoResponse: {
|
TrainingInfoResponse: {
|
||||||
|
|||||||
Reference in New Issue
Block a user