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

fix: Sonar maintainability #12

Merged
merged 1 commit into from
Nov 26, 2024
Merged
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
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
Loading