From 462b8149c9d5679c734751a53346a0eb00f27951 Mon Sep 17 00:00:00 2001 From: smagles Date: Tue, 26 Aug 2025 14:15:22 +0200 Subject: [PATCH 1/4] chore: optimize query for fetch active advertisement --- .../advertisement/AdvertisementRepository.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/ua/everybuy/database/repository/advertisement/AdvertisementRepository.java b/src/main/java/ua/everybuy/database/repository/advertisement/AdvertisementRepository.java index 709ef7a..10167d1 100644 --- a/src/main/java/ua/everybuy/database/repository/advertisement/AdvertisementRepository.java +++ b/src/main/java/ua/everybuy/database/repository/advertisement/AdvertisementRepository.java @@ -1,6 +1,7 @@ package ua.everybuy.database.repository.advertisement; import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; @@ -41,15 +42,8 @@ List findCategoryCountsByUserIdAndSection( "WHERE a.userId = :userId ") List findAllByUserId(Long userId); - @Query(""" - SELECT a FROM Advertisement a - LEFT JOIN FETCH a.city - LEFT JOIN FETCH a.topSubCategory tsc - LEFT JOIN FETCH tsc.category - LEFT JOIN FETCH a.lowSubCategory - LEFT JOIN FETCH a.advertisementDeliveries - WHERE a.id = :id AND a.isEnabled = true - """) + @EntityGraph(attributePaths = {"topSubCategory.category", "lowSubCategory", "advertisementDeliveries"}) + @Query("SELECT a FROM Advertisement a WHERE a.id = :id AND a.isEnabled = true") Optional findActiveById(@Param("id") Long id); @Query("SELECT a.city.id FROM Advertisement a " + From 3f23c7b3489743a04c0f69b3dd512fd4c6d4f907 Mon Sep 17 00:00:00 2001 From: smagles Date: Tue, 26 Aug 2025 14:17:49 +0200 Subject: [PATCH 2/4] chore: update postgres driver to latest version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ab59928..3350d41 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ dependencies { annotationProcessor 'org.projectlombok:lombok' implementation 'org.flywaydb:flyway-core' - runtimeOnly 'org.postgresql:postgresql:42.7.5' + runtimeOnly 'org.postgresql:postgresql' implementation("software.amazon.awssdk:s3:2.32.24") implementation 'org.mapstruct:mapstruct:1.5.2.Final' From ad7c334348b095e2f8b916fd3673bf9edf4fa3a0 Mon Sep 17 00:00:00 2001 From: smagles Date: Tue, 26 Aug 2025 14:35:08 +0200 Subject: [PATCH 3/4] create copilot-instructions.md --- .github/coderabbit.yml | 13 ------------- copilot-instructions.md | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 13 deletions(-) delete mode 100644 .github/coderabbit.yml create mode 100644 copilot-instructions.md diff --git a/.github/coderabbit.yml b/.github/coderabbit.yml deleted file mode 100644 index badd88f..0000000 --- a/.github/coderabbit.yml +++ /dev/null @@ -1,13 +0,0 @@ -mode: review - -review: - strategy: thorough - comments: inline - approve: false - summarization: true - -rules: - - type: code_quality - - type: security - - type: readability - - type: maintainability \ No newline at end of file diff --git a/copilot-instructions.md b/copilot-instructions.md new file mode 100644 index 0000000..2395956 --- /dev/null +++ b/copilot-instructions.md @@ -0,0 +1,25 @@ +# Pull Request Review Instructions + +Please review this pull request with the following guidelines: + +1. **Code Quality** + - Check for clear, maintainable, and efficient code. + - Ensure consistent naming, formatting, and conventions. + +2. **Security** + - Look for potential vulnerabilities, unsafe code, or insecure patterns. + +3. **Readability** + - Ensure code is easy to read and understand. + - Suggest improvements if logic is confusing or overly complex. + +4. **Maintainability** + - Check if code is modular and easy to extend or refactor. + - Identify repeated code or potential for simplification. + +5. **Comments & Feedback** + - Make inline comments for issues or suggestions. + - Summarize main suggestions at the end of the review. + +6. **Approval** + - Do not approve the PR automatically. From 4c6bf958f0e9d757bb9fbbc04c03a324d5ea6ee6 Mon Sep 17 00:00:00 2001 From: smagles Date: Tue, 26 Aug 2025 14:46:38 +0200 Subject: [PATCH 4/4] delete --- .github/workflows/ci.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 9f28462..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Code Review (AI PR Reviewer) - -on: - pull_request: - types: [opened, synchronize, reopened] - -permissions: - contents: read - pull-requests: write - -jobs: - review: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: AI PR Review and Summary - uses: fluxninja/openai-pr-reviewer@latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - with: - debug: false - review_simple_changes: true - review_comment_lgtm: true - review_comment_in_diff: true - summarize_changes: true