Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAGOPA-1326] business logic done #113

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/deploy_with_github_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
app_name: ${{ env.APP_NAME }}
helm_upgrade_options: "--debug"
timeout: '10m0s'

cleanup_runner:
name: Cleanup Runner
Expand Down
27 changes: 4 additions & 23 deletions .github/workflows/release_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
# Set Semvar
- run: echo "SEMVER=patch" >> $GITHUB_ENV

- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'breaking-change ')) }}
- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'breaking-change')) }}
run: echo "SEMVER=major" >> $GITHUB_ENV

# force semver if dev, !=main or skip release
Expand Down Expand Up @@ -121,36 +121,17 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.release.outputs.version }}

deploy_aks_dev:
name: Deploy on AKS DEV
deploy_aks:
name: Deploy on AKS ${{needs.setup.outputs.environment}}
needs: [ setup, release, image ]
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
uses: ./.github/workflows/deploy_with_github_runner.yml
with:
environment: ${{ needs.setup.outputs.environment }}
secrets: inherit

deploy_aks_uat:
name: Deploy on AKS UAT
needs: [ setup, release, image ]
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && needs.setup.outputs.environment != 'dev' }}
uses: ./.github/workflows/deploy_with_github_runner.yml
with:
environment: ${{ needs.setup.outputs.environment }}
secrets: inherit

deploy_aks_prod:
name: Deploy on AKS PROD
needs: [ setup, release, image ]
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && needs.setup.outputs.environment == 'prod' }}
uses: ./.github/workflows/deploy_with_github_runner.yml
with:
environment: ${{ needs.setup.outputs.environment }}
secrets: inherit


notify:
needs: [ setup, release, deploy_aks_prod ]
needs: [ setup, release, deploy_aks ]
runs-on: ubuntu-latest
name: Notify
if: always()
Expand Down
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-afm-calculator
description: Microservice that handles calculation for pagoPA Advanced Fees Management
type: application
version: 2.39.0
appVersion: 2.8.4
version: 2.40.0
appVersion: 2.8.4-1-PAGOPA-1326-sviluppo-modifica-calcolo-soglia-bundle
dependencies:
- name: microservice-chart
version: 2.4.0
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-afm-calculator
tag: "2.8.4"
tag: "2.8.4-1-PAGOPA-1326-sviluppo-modifica-calcolo-soglia-bundle"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-afm-calculator
tag: "2.8.4"
tag: "2.8.4-1-PAGOPA-1326-sviluppo-modifica-calcolo-soglia-bundle"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-afm-calculator
tag: "2.8.4"
tag: "2.8.4-1-PAGOPA-1326-sviluppo-modifica-calcolo-soglia-bundle"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-node.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic for Node",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.8.4"
"version": "2.8.4-1-PAGOPA-1326-sviluppo-modifica-calcolo-soglia-bundle"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.8.4"
"version": "2.8.4-1-PAGOPA-1326-sviluppo-modifica-calcolo-soglia-bundle"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>calculator</artifactId>
<version>2.8.4</version>
<version>2.8.4-1-PAGOPA-1326-sviluppo-modifica-calcolo-soglia-bundle</version>
<name>afm-calculator</name>
<description>Calculator Logic microservice for pagoPA AFM</description>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package it.gov.pagopa.afm.calculator.repository;

import static it.gov.pagopa.afm.calculator.service.UtilityComponent.isGlobal;
import static it.gov.pagopa.afm.calculator.util.CriteriaBuilder.*;

import com.azure.cosmos.implementation.guava25.collect.Iterables;
import com.azure.spring.data.cosmos.core.CosmosTemplate;
import com.azure.spring.data.cosmos.core.query.CosmosQuery;
Expand All @@ -16,20 +13,20 @@
import it.gov.pagopa.afm.calculator.model.PspSearchCriteria;
import it.gov.pagopa.afm.calculator.service.UtilityComponent;
import it.gov.pagopa.afm.calculator.util.CriteriaBuilder;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Repository;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import static it.gov.pagopa.afm.calculator.service.UtilityComponent.isGlobal;
import static it.gov.pagopa.afm.calculator.util.CriteriaBuilder.*;

@Repository
public class CosmosRepository {

Expand Down Expand Up @@ -70,9 +67,9 @@ private Iterable<ValidBundle> findValidBundles(PaymentOption paymentOption, bool

// add filter by Payment Amount: minPaymentAmount <= paymentAmount < maxPaymentAmount
var minFilter =
CriteriaBuilder.lessThanEqual("minPaymentAmount", paymentOption.getPaymentAmount());
CriteriaBuilder.lessThan("minPaymentAmount", paymentOption.getPaymentAmount());
var maxFilter =
CriteriaBuilder.greaterThan("maxPaymentAmount", paymentOption.getPaymentAmount());
CriteriaBuilder.greaterThanEqual("maxPaymentAmount", paymentOption.getPaymentAmount());
var queryResult = and(minFilter, maxFilter);

// add filter by Touch Point: touchpoint=<value> || touchpoint==null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import com.azure.spring.data.cosmos.core.query.Criteria;
import com.azure.spring.data.cosmos.core.query.CriteriaType;
import java.util.Collections;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.experimental.UtilityClass;
import org.springframework.data.repository.query.parser.Part;

import javax.validation.constraints.NotNull;
import java.util.Collections;
import java.util.List;

@UtilityClass
public class CriteriaBuilder {

Expand Down Expand Up @@ -70,17 +71,17 @@ public static <T> Criteria arrayContains(String param, T value) {
Part.IgnoreCaseType.NEVER);
}

public static Criteria greaterThan(String param, Long value) {
public static Criteria greaterThanEqual(String param, Long value) {
return Criteria.getInstance(
CriteriaType.GREATER_THAN,
CriteriaType.GREATER_THAN_EQUAL,
param,
Collections.singletonList(value),
Part.IgnoreCaseType.NEVER);
}

public static Criteria lessThanEqual(String param, Long value) {
public static Criteria lessThan(String param, Long value) {
return Criteria.getInstance(
CriteriaType.LESS_THAN_EQUAL,
CriteriaType.LESS_THAN,
param,
Collections.singletonList(value),
Part.IgnoreCaseType.NEVER);
Expand Down