Skip to content

Commit

Permalink
sonar maintainability
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitolo-Andrea committed Nov 26, 2024
1 parent c071443 commit 8cfb044
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class CitizenSpecificRepositoryImpl implements CitizenSpecificRepository

private final ReactiveMongoTemplate mongoTemplate;

private static final String FISCAL_CODE = "fiscalCode";

public CitizenSpecificRepositoryImpl(ReactiveMongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}
Expand All @@ -26,9 +28,9 @@ public Mono<CitizenConsent> findByFiscalCodeAndTppId(String fiscalCode, String t

String consent = "consents." + tppId;
Aggregation aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where("fiscalCode").is(fiscalCode)),
Aggregation.match(Criteria.where(FISCAL_CODE).is(fiscalCode)),
Aggregation.match(Criteria.where(consent).exists(true)),
Aggregation.project("fiscalCode").and(consent).as(consent)
Aggregation.project(FISCAL_CODE).and(consent).as(consent)
);

return mongoTemplate.aggregate(aggregation, "citizen_consents", CitizenConsent.class)
Expand All @@ -41,7 +43,7 @@ public Flux<CitizenConsent> findByTppIdEnabled(String tppId) {

Aggregation aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where(tppStatePath).is(true)),
Aggregation.project("fiscalCode").and(consent).as(consent)
Aggregation.project(FISCAL_CODE).and(consent).as(consent)
);

return mongoTemplate.aggregate(aggregation, "citizen_consents", CitizenConsent.class);
Expand Down

0 comments on commit 8cfb044

Please sign in to comment.