Skip to content

Commit

Permalink
fix: Sonar maintainability (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitolo-Andrea authored Nov 26, 2024
1 parent c071443 commit 30e765f
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 30e765f

Please sign in to comment.