style: apply ktlint again to project

This commit is contained in:
Gauthier Roebroeck 2021-02-17 16:59:44 +08:00
parent ba6bed7766
commit 0216cc2cf5
10 changed files with 24 additions and 25 deletions

View file

@ -35,7 +35,7 @@ class FileSystemScanner(
logger.info { "Excluded patterns: ${komgaProperties.librariesScanDirectoryExclusions}" }
logger.info { "Force directory modified time: $forceDirectoryModifiedTime" }
if(!(Files.isDirectory(root) && Files.isReadable(root)))
if (!(Files.isDirectory(root) && Files.isReadable(root)))
throw DirectoryNotFoundException("Library root is not accessible: $root")
lateinit var scannedSeries: Map<Series, List<Book>>

View file

@ -7,7 +7,7 @@ import org.springframework.stereotype.Service
@Service
class MetadataAggregator {
fun aggregate(metadatas: Collection<BookMetadata>) : BookMetadataAggregation {
fun aggregate(metadatas: Collection<BookMetadata>): BookMetadataAggregation {
val authors = metadatas.flatMap { it.authors }.distinctBy { "${it.role}__${it.name}" }
val (summary, summaryNumber) = metadatas.sortedBy { it.numberSort }.find { it.summary.isNotBlank() }?.let {
it.summary to it.number

View file

@ -195,7 +195,7 @@ class MetadataLifecycle(
}
}
fun aggregateMetadata(series: Series){
fun aggregateMetadata(series: Series) {
logger.info { "Aggregate book metadata for series: $series" }
val metadatas = bookMetadataRepository.findByIds(bookRepository.findAllIdBySeriesId(series.id))

View file

@ -169,10 +169,10 @@ class ReferentialDao(
override fun findAllSeriesReleaseDates(): Set<LocalDate> =
dsl.selectDistinct(bma.RELEASE_DATE)
.from(bma)
.where(bma.RELEASE_DATE.isNotNull)
.orderBy(bma.RELEASE_DATE.desc())
.fetchSet(bma.RELEASE_DATE)
.from(bma)
.where(bma.RELEASE_DATE.isNotNull)
.orderBy(bma.RELEASE_DATE.desc())
.fetchSet(bma.RELEASE_DATE)
override fun findAllSeriesReleaseDatesByLibrary(libraryId: String): Set<LocalDate> =
dsl.selectDistinct(bma.RELEASE_DATE)

View file

@ -196,7 +196,7 @@ class SeriesDtoDao(
val aggregatedAuthors = dsl.selectFrom(bmaa)
.where(bmaa.SERIES_ID.eq(sr.id))
.fetchInto(bmaa)
.filter {it.name != null }
.filter { it.name != null }
.map { AuthorDto(it.name, it.role) }
sr.toDto(booksCount, booksReadCount, booksUnreadCount, booksInProgressCount, dr.toDto(genres, tags), bmar.toDto(aggregatedAuthors))
@ -219,7 +219,7 @@ class SeriesDtoDao(
c = c.and(c1.or(c2))
}
// cast to String is necessary for SQLite, else the years in the IN block are coerced to Int, even though YEAR for SQLite uses strftime (string)
if(!releaseYears.isNullOrEmpty()) c = c.and(DSL.year(bma.RELEASE_DATE).cast(String::class.java).`in`(releaseYears))
if (!releaseYears.isNullOrEmpty()) c = c.and(DSL.year(bma.RELEASE_DATE).cast(String::class.java).`in`(releaseYears))
return c
}

View file

@ -402,11 +402,13 @@ class SeriesController(
}
return ResponseEntity.ok()
.headers(HttpHeaders().apply {
contentDisposition = ContentDisposition.builder("attachment")
.filename(seriesMetadataRepository.findById(seriesId).title + ".zip")
.build()
})
.headers(
HttpHeaders().apply {
contentDisposition = ContentDisposition.builder("attachment")
.filename(seriesMetadataRepository.findById(seriesId).title + ".zip")
.build()
}
)
.contentType(MediaType.parseMediaType("application/zip"))
.body(streamingResponse)
}

View file

@ -1,7 +1,6 @@
package org.gotson.komga.interfaces.rest.dto
import com.fasterxml.jackson.annotation.JsonFormat
import org.gotson.komga.domain.model.Author
import java.time.LocalDate
import java.time.LocalDateTime

View file

@ -8,7 +8,6 @@ import org.assertj.core.api.Assertions.catchThrowable
import org.gotson.komga.domain.model.DirectoryNotFoundException
import org.gotson.komga.infrastructure.configuration.KomgaProperties
import org.junit.jupiter.api.Test
import java.lang.Exception
import java.nio.file.Files
import java.nio.file.Path

View file

@ -10,10 +10,10 @@ class MetadataAggregatorTest {
private val aggregator = MetadataAggregator()
@Test
fun `given metadatas when aggregating then aggregation is relevant`(){
fun `given metadatas when aggregating then aggregation is relevant`() {
val metadatas = listOf(
BookMetadata(title = "ignored", summary = "summary 1", number = "1", numberSort = 1F, authors = listOf(Author("author1", "role1"), Author("author2", "role2")), releaseDate = LocalDate.of(2020, 1,1)),
BookMetadata(title = "ignored", summary = "summary 2", number = "2", numberSort = 2F, authors = listOf(Author("author3", "role3"), Author("author2", "role3")), releaseDate = LocalDate.of(2021, 1,1)),
BookMetadata(title = "ignored", summary = "summary 1", number = "1", numberSort = 1F, authors = listOf(Author("author1", "role1"), Author("author2", "role2")), releaseDate = LocalDate.of(2020, 1, 1)),
BookMetadata(title = "ignored", summary = "summary 2", number = "2", numberSort = 2F, authors = listOf(Author("author3", "role3"), Author("author2", "role3")), releaseDate = LocalDate.of(2021, 1, 1)),
)
val aggregation = aggregator.aggregate(metadatas)
@ -25,7 +25,7 @@ class MetadataAggregatorTest {
}
@Test
fun `given metadatas with summary only on second book when aggregating then aggregation has second book's summary`(){
fun `given metadatas with summary only on second book when aggregating then aggregation has second book's summary`() {
val metadatas = listOf(
BookMetadata(title = "ignored", number = "1", numberSort = 1F),
BookMetadata(title = "ignored", summary = "summary 2", number = "2", numberSort = 2F),
@ -38,10 +38,10 @@ class MetadataAggregatorTest {
}
@Test
fun `given metadatas with second book with earlier release date when aggregating then aggregation has release date from second book`(){
fun `given metadatas with second book with earlier release date when aggregating then aggregation has release date from second book`() {
val metadatas = listOf(
BookMetadata(title = "ignored", number = "1", numberSort = 1F, releaseDate = LocalDate.of(2020, 1,1)),
BookMetadata(title = "ignored", number = "2", numberSort = 2F, releaseDate = LocalDate.of(2019, 1,1)),
BookMetadata(title = "ignored", number = "1", numberSort = 1F, releaseDate = LocalDate.of(2020, 1, 1)),
BookMetadata(title = "ignored", number = "2", numberSort = 2F, releaseDate = LocalDate.of(2019, 1, 1)),
)
val aggregation = aggregator.aggregate(metadatas)
@ -50,7 +50,7 @@ class MetadataAggregatorTest {
}
@Test
fun `given metadatas with duplicate authors when aggregating then aggregation has no duplicate authors`(){
fun `given metadatas with duplicate authors when aggregating then aggregation has no duplicate authors`() {
val metadatas = listOf(
BookMetadata(title = "ignored", number = "1", numberSort = 1F, authors = listOf(Author("author1", "role1"), Author("author2", "role2"))),
BookMetadata(title = "ignored", number = "2", numberSort = 2F, authors = listOf(Author("author1", "role1"), Author("author2", "role2"))),

View file

@ -269,7 +269,6 @@ class SeriesControllerTest(
}
}
@Nested
inner class RestrictedUserByRole {
@Test