Skip to content

Commit

Permalink
⚡ Prod vaadin
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbatovK committed Mar 25, 2024
1 parent 7709907 commit 5ba7d44
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.google.cloud.tools.jib.gradle.JibExtension
import com.vaadin.gradle.vaadin
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
Expand Down Expand Up @@ -36,6 +37,13 @@ noArg {
group = "com.albatros"
version = "0.0.1-SNAPSHOT"

vaadin {
pnpmEnable = true
productionMode = true
generateBundle = true
optimizeBundle = trueg
}

java {
sourceCompatibility = JavaVersion.VERSION_17
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.springframework.data.domain.Pageable
import org.springframework.data.elasticsearch.annotations.Query
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
import org.springframework.stereotype.Repository
import java.util.stream.Stream

@Repository
interface TenderSearchRepository : ElasticsearchRepository<Tender, String> {
Expand All @@ -20,7 +21,7 @@ interface TenderSearchRepository : ElasticsearchRepository<Tender, String> {
"query": "?0",
"fields": ["tender_name^5", "tender_id^15", "region^5", "etp^10", "fz", "meta_data", "user_id", "category^10", "customer^15", "date"],
"operator": "AND",
"fuzziness": "2",
"fuzziness": "AUTO",
"minimum_should_match": "2",
"type": "best_fields"
}
Expand All @@ -32,7 +33,7 @@ interface TenderSearchRepository : ElasticsearchRepository<Tender, String> {
"query": "?1",
"fields": ["tender_name^5", "tender_id^15", "region^5", "etp^10", "fz", "meta_data", "user_id", "category^10", "customer^15", "date"],
"operator": "AND",
"fuzziness": "2",
"fuzziness": "AUTO",
"type": "best_fields"
}
}
Expand All @@ -41,7 +42,7 @@ interface TenderSearchRepository : ElasticsearchRepository<Tender, String> {
}
"""
)
fun fullTextSearchAnd(keywords: String): List<Tender>
fun fullTextSearchAnd(keywords: String, exclude: String, pageable: Pageable): Stream<Tender>

@Query(
"""
Expand All @@ -53,7 +54,7 @@ interface TenderSearchRepository : ElasticsearchRepository<Tender, String> {
"query": "?0",
"fields": ["tender_name^5", "tender_id^15", "region^5", "etp^10", "fz", "meta_data", "user_id", "category^10", "customer^15", "date"],
"operator": "OR",
"fuzziness": "2",
"fuzziness": "AUTO",
"type": "best_fields"
}
}
Expand All @@ -64,7 +65,7 @@ interface TenderSearchRepository : ElasticsearchRepository<Tender, String> {
"query": "?1",
"fields": ["tender_name^5", "tender_id^15", "region^5", "etp^10", "fz", "meta_data", "user_id", "category^10", "customer^15", "date"],
"operator": "AND",
"fuzziness": "2",
"fuzziness": "AUTO",
"type": "best_fields"
}
}
Expand All @@ -73,7 +74,7 @@ interface TenderSearchRepository : ElasticsearchRepository<Tender, String> {
}
"""
)
fun fullTextSearchOr(keywords: String, exclude: String): List<Tender>
fun fullTextSearchOr(keywords: String, exclude: String): Stream<Tender>
fun findAllByTenderId(tenderId: String, pageable: Pageable): Page<Tender>

fun findAllByCustomerContainsIgnoreCase(customer: String, pageable: Pageable): Page<Tender>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class TenderController(
) {

@PostMapping("/full-text-search")
fun getAll(@RequestBody fullTextSearchRequest: FullTextSearchRequest): List<Tender> {
fun getAll(@RequestBody fullTextSearchRequest: FullTextSearchRequest, pageable: Pageable): List<Tender> {
return tenderRepository.fullTextSearchOr(
fullTextSearchRequest.include, fullTextSearchRequest.exclude
)
).toList()
}

@GetMapping("/provider/")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
package com.albatros.springsecurity.presentation.route

import com.albatros.springsecurity.data.model.database.Tender
import com.albatros.springsecurity.data.model.database.TenderProvider
import com.albatros.springsecurity.data.repository.TenderProviderRepository
import com.albatros.springsecurity.data.repository.TenderSearchRepository
import com.vaadin.flow.component.Text
import com.vaadin.flow.component.button.Button
import com.vaadin.flow.component.button.ButtonVariant
import com.vaadin.flow.component.grid.Grid
import com.vaadin.flow.component.html.Paragraph
import com.vaadin.flow.component.icon.VaadinIcon
import com.vaadin.flow.component.notification.Notification
import com.vaadin.flow.component.orderedlayout.HorizontalLayout
import com.vaadin.flow.component.orderedlayout.VerticalLayout
import com.vaadin.flow.component.textfield.TextField
import com.vaadin.flow.router.Route
import com.vaadin.flow.spring.data.VaadinSpringDataHelpers


@Route("test")
class TestRoute(repository: TenderSearchRepository) : VerticalLayout() {
Expand Down Expand Up @@ -59,15 +52,15 @@ class TestRoute(repository: TenderSearchRepository) : VerticalLayout() {
height = "600px"
}

val button = Button("Найти", VaadinIcon.SEARCH.create()){
val button = Button("Найти", VaadinIcon.SEARCH.create()) {
val includeText = includeTextField.value
val excludeText = excludeTextField.value

sheet.setItems(
repository.fullTextSearchOr(
includeText,
excludeText,
)
).toList()
)
}

Expand Down

0 comments on commit 5ba7d44

Please sign in to comment.