Skip to content

Feature/conluz 189#192

Merged
viktorKhan merged 7 commits into
mainfrom
feature/conluz-189
Jul 3, 2026
Merged

Feature/conluz 189#192
viktorKhan merged 7 commits into
mainfrom
feature/conluz-189

Conversation

@viktorKhan

Copy link
Copy Markdown
Contributor

No description provided.

viktorKhan and others added 3 commits July 3, 2026 11:47
Mirror the Datadis consumption monthly aggregation for production:
- Domain service + repository port under domain/production/datadis/aggregate
- InfluxDB impl aggregating hourly datadis_production_kwh into
  datadis_production_kwh_month via SUM(production_kwh)/LAST(obtain_method),
  GROUP BY cups, with a deterministic first-of-month timestamp so re-runs
  overwrite instead of duplicating
- Monthly aggregation job (cron 5AM, after the 4AM hourly sync)
- DatadisProductionMonthlyPoint read model
- Arch-test exception for the non-transactional aggregation service
- Influx integration test: per-cups sums across two months, deterministic
  timestamp, and idempotent re-run

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mirror the Datadis consumption yearly aggregation for production:
- Domain service + repository port under domain/production/datadis/aggregate
- InfluxDB impl reading the monthly datadis_production_kwh_month measurement
  and writing datadis_production_kwh_year via SUM(production_kwh)/
  LAST(obtain_method), GROUP BY cups, with a deterministic Jan-1 timestamp
- Yearly aggregation job (cron 6AM, after the 5AM monthly aggregation)
- DatadisProductionYearlyPoint read model
- Arch-test exception for the non-transactional aggregation service
- Influx integration test: per-cups yearly sums from monthly points,
  deterministic timestamp, and idempotent re-run

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Expose manual triggers for the monthly and yearly Datadis production
aggregations, mirroring the consumption sync controllers:
- POST /api/v1/communities/{communityId}/production/datadis/sync/monthly
- POST /api/v1/communities/{communityId}/production/datadis/sync/yearly
- Authorization lives only in the controller via
  @communityAccessGuard.canManageCommunity(#communityId); OpenAPI tag
  ApiTag.PRODUCTION; gated on the community's Datadis config being enabled
  (409 otherwise)
- Request bodies with year/month/supplyCode validation
- Security matrix tests per endpoint: 401 (no token), 403 (member who
  cannot manage), 404 (community not visible), happy path verifying the
  service is invoked, plus 409-disabled and validation cases

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@viktorKhan viktorKhan linked an issue Jul 3, 2026 that may be closed by this pull request
viktorKhan and others added 4 commits July 3, 2026 12:02
Cover DatadisProductionMonthlyAggregationServiceImpl and
DatadisProductionYearlyAggregationServiceImpl with Mockito unit tests,
mirroring the consumption aggregation service tests: global/community/
single-supply overloads, skipping supplies without a distributor code,
per-supply exception isolation, and SupplyNotFoundException for missing or
cross-community supplies. Tests are named after the service interfaces.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The production Datadis sync controllers embedded domain logic (config
gating that called GetDatadisConfigRepository directly, plus supply/month
dispatch branching). Controllers must be thin and never call repositories.

- Add syncMonthlyProductions/syncYearlyProductions to the aggregation
  services; the service impls now own the Datadis-enabled precondition
  (throwing DatadisDisabledException) and all the supply/month dispatch,
  delegating to the granular aggregation methods.
- Controllers now only authorize, validate the body, and make a single
  service call. Removed the GetDatadisConfigRepository dependency and the
  now-unused getMonthEnum() from the monthly body.
- Move the config-gating and dispatch assertions from the controller tests
  into the service unit tests; controller tests now assert pass-through and
  that service-thrown exceptions map to 409/404.
- CLAUDE.md: add a standard requiring thin controllers (no domain logic,
  no repository calls).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move the config gating and supply/plant dispatch out of every Datadis and
Huawei sync controller and into the services, so controllers only authorize,
validate the body, and make a single service call — never touching a
repository.

- Consumption aggregation: add syncMonthly/YearlyConsumptions to the
  services (Datadis config gating + dispatch); thin the monthly/yearly
  controllers; drop the unused getMonthEnum from the monthly body.
- Hourly consumption sync: add synchronize(..., String supplyCode) to
  DatadisSyncService (config gating + dispatch); thin the controller.
- Huawei aggregation: add syncMonthly/YearlyProductions to the services
  (Huawei config gating + dispatch); thin the monthly/yearly controllers;
  drop the unused getMonthEnum from the monthly body.
- Move the config-gating/dispatch assertions from the controller tests into
  the service unit tests; controller tests now assert pass-through and that
  service-thrown exceptions map to 409/404, plus the 401/403/404 matrix.
- Add ControllerRepositoryAccessArchTest: no @Controller/@RestController may
  depend on a *Repository / *RepositoryDatabase / *RepositoryInflux type.
- CLAUDE.md: reference the new arch test from the thin-controller rule.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@viktorKhan viktorKhan merged commit f1e6b46 into main Jul 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task 2 - Monthly and yearly Datadis production aggregation

1 participant