Skip to content

Commit

Permalink
Bump kotlinVersion from 2.0.0 to 2.1.0 (#78)
Browse files Browse the repository at this point in the history
* Bump kotlinVersion from 2.0.0 to 2.1.0

Bumps `kotlinVersion` from 2.0.0 to 2.1.0.

Updates `jvm` from 2.0.0 to 2.1.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v2.1.0/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.0...v2.1.0)

Updates `plugin.spring` from 2.0.0 to 2.1.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v2.1.0/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.0...v2.1.0)

Updates `plugin.jpa` from 2.0.0 to 2.1.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v2.1.0/ChangeLog.md)
- [Commits](JetBrains/kotlin@v2.0.0...v2.1.0)

---
updated-dependencies:
- dependency-name: jvm
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: plugin.spring
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: plugin.jpa
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix spotless

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Stefan Bratanov <stefan.bratanov93@gmail.com>
  • Loading branch information
dependabot[bot] and StefanBratanov authored Dec 2, 2024
1 parent 37ed625 commit 603a7e7
Show file tree
Hide file tree
Showing 42 changed files with 84 additions and 256 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import com.diffplug.gradle.spotless.SpotlessExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
val kotlinVersion = "2.0.0"
val kotlinVersion = "2.1.0"
kotlin("jvm") version kotlinVersion
kotlin("plugin.spring") version kotlinVersion
kotlin("plugin.jpa") version kotlinVersion
Expand Down Expand Up @@ -91,6 +91,6 @@ tasks.withType<Test> {
testLogging { showStandardStreams = true }
}

configure<SpotlessExtension> { kotlin { ktfmt().googleStyle() } }
configure<SpotlessExtension> { kotlin { ktfmt("0.53").googleStyle() } }

tasks.jacocoTestReport { reports { xml.required.set(true) } }
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun main(args: Array<String>) {
@Component
class Main(
val scheduledFlowsRunner: ScheduledFlowsRunner,
val alcoholController: AlcoholController
val alcoholController: AlcoholController,
) : CommandLineRunner {

override fun run(vararg args: String?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ class AlcoholController(
listOf(bira, vino, "(?<!без)алкохолни", cider).map { it.toRegex(IGNORE_CASE) }

private val tMarketCategoryResolver =
mapOf(
Beer to bira,
Wine to vino,
Other to cider,
)
.mapValues { it.value.toRegex(IGNORE_CASE) }
mapOf(Beer to bira, Wine to vino, Other to cider).mapValues { it.value.toRegex(IGNORE_CASE) }

private val kauflandDrinksCategoryRegex = "Алкохол".toRegex(IGNORE_CASE)

Expand Down Expand Up @@ -110,7 +105,7 @@ class AlcoholController(
"cappy",
"препарат",
"диспенсър",
"асортимента"
"асортимента",
)
.map { it.toRegex(IGNORE_CASE) }

Expand Down Expand Up @@ -156,13 +151,7 @@ class AlcoholController(
// filter regexes
?.filter { ignoreContains.none { regex -> it.name.contains(regex) } }
// remove same products
?.distinctBy { pr ->
pr.copy(
validFrom = null,
validUntil = null,
picUrl = null,
)
}
?.distinctBy { pr -> pr.copy(validFrom = null, validUntil = null, picUrl = null) }
it.copy(products = filteredAndDistinctProducts)
}
.map { addPics(it, useCdn) }
Expand Down Expand Up @@ -249,6 +238,6 @@ class AlcoholController(
Rakia,
Vodka,
Whiskey,
Other
Other,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration
class ApiConfig(
val buildProperties: BuildProperties,
) : WebMvcConfigurer {
class ApiConfig(val buildProperties: BuildProperties) : WebMvcConfigurer {

override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
Expand All @@ -31,10 +29,8 @@ class ApiConfig(
.description("API за извличане на информация за продукти от супермаркети в София")
.version(buildProperties.version)
.contact(Contact().email("stefan.bratanov93@gmail.com"))
.license(
License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0"),
)
.termsOfService("urn:tos"),
.license(License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0"))
.termsOfService("urn:tos")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import org.springframework.web.bind.annotation.RestController

@Tag(name = "Product", description = "All operations for supermarket products")
@RestController
class ProductStoreController(
val productStoreRepository: ProductStoreRepository,
) {
class ProductStoreController(val productStoreRepository: ProductStoreRepository) {

@Operation(summary = "Get all products from supermarkets")
@GetMapping("/products")
Expand Down Expand Up @@ -41,9 +39,7 @@ class ProductStoreController(
private fun checkOfferPrice(product: Product): Boolean {
return nonNull(product.oldPrice) &&
nonNull(product.price) &&
product.oldPrice?.equals(
product.price,
) == false &&
product.oldPrice?.equals(product.price) == false &&
compareValues(product.price, product.oldPrice) < 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import org.springframework.stereotype.Component

@Log
@Component
class FantasticoBrochureDownloader(
@Value("\${fantastico.url}") private val url: URL,
) : BrochureDownloader {
class FantasticoBrochureDownloader(@Value("\${fantastico.url}") private val url: URL) :
BrochureDownloader {

companion object {
var capabilities: DesiredCapabilities
Expand Down Expand Up @@ -72,7 +71,7 @@ class FantasticoBrochureDownloader(
val nameOfBrochure = it.selectFirst("p.paragraph")?.text()
val dateRange = extractDateRange(nameOfBrochure)
log.info(
"Fantastico brochure is vaild " + "from ${dateRange?.first} until ${dateRange?.second}",
"Fantastico brochure is vaild " + "from ${dateRange?.first} until ${dateRange?.second}"
)

val iFrameUrl = it.attr("data-brochure")
Expand Down Expand Up @@ -136,10 +135,7 @@ class FantasticoBrochureDownloader(
}

private fun addYearIfApplicable(input: String): String {
return input.replace(
"(\\.|(?<=\\.\\d{2}))\$".toRegex(),
".${LocalDate.now().year}",
)
return input.replace("(\\.|(?<=\\.\\d{2}))\$".toRegex(), ".${LocalDate.now().year}")
}

private fun clickBrochure(dataId: String, waitDriver: WebDriverWait) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BillaProductsExtractor : UrlProductsExtractor {
"(?<=МУЛТИ ПАК.+)\\d+(х|x)".toRegex(IGNORE_CASE),
"МУЛТИ ПАК (\\d+\\+\\d+)?".toRegex(IGNORE_CASE),
"(\\d+(х|x)\\s*)?Цена\\s+за\\s+\\d+\\s*бр\\.\\s*((без|с)\\s+отстъпка)?\\s*(\\d|\\.|,)+\\s*лв\\."
.toRegex(IGNORE_CASE)
.toRegex(IGNORE_CASE),
)

private val regexesToDeleteBilla =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,10 @@ class FantasticoProductsExtractor : PdfProductsExtractor {
".*Работно време.*".toRegex(RegexOption.IGNORE_CASE),
".*Във всички обекти на верига Фантастико.*".toRegex(RegexOption.IGNORE_CASE),
"Според потребителската класация".toRegex(RegexOption.IGNORE_CASE),
"ТВ „Фантастико” не носи отговорност.*".toRegex(RegexOption.IGNORE_CASE)
"ТВ „Фантастико” не носи отговорност.*".toRegex(RegexOption.IGNORE_CASE),
)

private val fontsToKeep =
listOf(
myriadProRegex,
officinaSansRegex,
bebasNeueRegex,
)
private val fontsToKeep = listOf(myriadProRegex, officinaSansRegex, bebasNeueRegex)

private val regexesToRemove =
listOf(
Expand All @@ -63,7 +58,7 @@ class FantasticoProductsExtractor : PdfProductsExtractor {
"количествата са лимитирани".toRegex(RegexOption.IGNORE_CASE),
"предложението е валидно(.*цени)?".toRegex(RegexOption.IGNORE_CASE),
"от.*до.*г\\.".toRegex(RegexOption.IGNORE_CASE),
"цена за периода.*г\\.".toRegex(RegexOption.IGNORE_CASE)
"цена за периода.*г\\.".toRegex(RegexOption.IGNORE_CASE),
)

private val productSectionResolver: Map<ProductSection, (TextWithCoordinates) -> Boolean> =
Expand All @@ -73,22 +68,13 @@ class FantasticoProductsExtractor : PdfProductsExtractor {
NEW_PRICE to
{ twc ->
twc.text!!.matches("\\d{1,2}(\\*?)".toRegex()) &&
twc.font
?.name
?.contains(
bebasNeueRegex,
) == true
twc.font?.name?.contains(bebasNeueRegex) == true
},
DISCOUNT to { twc -> twc.text!!.matches("-?\\d{1,2}%".toRegex()) },
CURRENCY to { twc -> twc.text!!.contains("лв|") },
QUANTITY to
{ twc ->
twc.text!!.contains(
"\\d+\\s*(мл|г|л|бр|см)"
.toRegex(
RegexOption.IGNORE_CASE,
),
)
twc.text!!.contains("\\d+\\s*(мл|г|л|бр|см)".toRegex(RegexOption.IGNORE_CASE))
},
NAME to { twc -> twc.font?.name?.contains(myriadProRegex) == true },
UNKNOWN to { true },
Expand Down Expand Up @@ -135,12 +121,7 @@ class FantasticoProductsExtractor : PdfProductsExtractor {
}
.takeUnless { text -> Strings.isBlank(text) }
.let { text ->
regexesToRemove.fold(text) { q, toRemove ->
q?.replace(
toRemove,
"",
)
}
regexesToRemove.fold(text) { q, toRemove -> q?.replace(toRemove, "") }
}
.let { text -> removeDuplicateSubstrings(text) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import org.springframework.stereotype.Component

@Log
@Component("Kaufland")
class KauflandProductsExtractor(
private val urlValidator: UrlValidator = UrlValidator(),
) : UrlProductsExtractor {
class KauflandProductsExtractor(private val urlValidator: UrlValidator = UrlValidator()) :
UrlProductsExtractor {

override fun extract(url: URL): List<Product> {
val document =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LidlProductExtractor {
category = null,
picUrl = null,
validFrom = dateRange?.elementAtOrNull(0),
validUntil = dateRange?.elementAtOrNull(1)
validUntil = dateRange?.elementAtOrNull(1),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component
@Component("Lidl")
class LidlProductsExtractor(
@Value("\${lidl.base.url}") private val baseUrl: URL,
val lidlProductExtractor: LidlProductExtractor
val lidlProductExtractor: LidlProductExtractor,
) : UrlProductsExtractor {

@OptIn(DelicateCoroutinesApi::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ class TMarketProductsExtractor : UrlProductsExtractor {
val endDate =
it.selectFirst("div[data-end-date]")?.attr("data-end-date")?.let { date ->
try {
LocalDateTime.parse(
date,
DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"),
)
LocalDateTime.parse(date, DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"))
.toLocalDate()
} catch (ex: Exception) {
log.error("Error while parsing $date", ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import org.springframework.stereotype.Component

@Log
@Component
class CloudinaryCdnUploader(
private val cloudinary: Cloudinary,
) : CdnUploader {
class CloudinaryCdnUploader(private val cloudinary: Cloudinary) : CdnUploader {

@Cacheable("cdnImages")
@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class GoogleImageSearch(
val title: String?,
val link: String?,
val fileFormat: String?,
val image: Image
val image: Image,
)

data class Image(val height: Double, val width: Double)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ class ImageConfig {
@Value("\${cloudinary.api.secret}") apiSecret: String,
): Cloudinary {
return Cloudinary(
ObjectUtils.asMap(
"cloud_name",
cloudName,
"api_key",
apiKey,
"api_secret",
apiSecret,
),
ObjectUtils.asMap("cloud_name", cloudName, "api_key", apiKey, "api_secret", apiSecret)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import org.springframework.stereotype.Component

@Log
@Component
class BillaSublinksScraper(
@Value("\${billa.url}") private val url: URL,
) : SublinksScraper {
class BillaSublinksScraper(@Value("\${billa.url}") private val url: URL) : SublinksScraper {

override fun getSublinks(): List<URL> {
log.info("Scraping {} for sublinks", url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import org.springframework.stereotype.Component

@Log
@Component
class KauflandSublinksScraper(
@Value("\${kaufland.base.url}") private val baseUrl: URL,
) : SublinksScraper {
class KauflandSublinksScraper(@Value("\${kaufland.base.url}") private val baseUrl: URL) :
SublinksScraper {

override fun getSublinks(): List<URL> {
log.info("Scraping {} for sublinks", baseUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import org.springframework.stereotype.Component

@Log
@Component
class LidlSublinksScraper(
@Value("\${lidl.base.url}") private val baseUrl: URL,
) : SublinksScraper {
class LidlSublinksScraper(@Value("\${lidl.base.url}") private val baseUrl: URL) : SublinksScraper {

override fun getSublinks(): List<URL> {
log.info("Scraping {} for sublinks", baseUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,7 @@ class KMeansWithInitialCenters(
return minCluster
}

private fun centroidOf(
points: Collection<TextWithCoordinates>,
dimension: Int,
): Clusterable {
private fun centroidOf(points: Collection<TextWithCoordinates>, dimension: Int): Clusterable {
val centroid = DoubleArray(dimension)
for (p in points) {
val point: DoubleArray = p.point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ package com.stefanbratanov.sofiasupermarketsapi.model
import jakarta.persistence.Entity
import jakarta.persistence.Id

@Entity
data class ProductImage(
@Id val product: String,
var url: String?,
)
@Entity data class ProductImage(@Id val product: String, var url: String?)
Loading

0 comments on commit 603a7e7

Please sign in to comment.