Skip to content

Conversation

@lucas-oristanio
Copy link
Member

No description provided.

@lucas-oristanio lucas-oristanio marked this pull request as ready for review June 8, 2025 21:57
@ezpmartins ezpmartins closed this Jun 8, 2025
@ezpmartins ezpmartins reopened this Jun 8, 2025
@ezpmartins ezpmartins requested review from Copilot and ezpmartins and removed request for leOhsantos June 8, 2025 22:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR corrects the dashboard KPI queries and service logic to produce accurate metrics, and adjusts the scheduling frequency for insight fetching.

  • Updated InsightsScheduler to run every 5 minutes instead of hourly.
  • Refactored DashboardService to use new aggregated repository methods and recalculate KPI rates in code.
  • Added two new repository queries for basic metrics and last-post reach, and updated the controller to match the new service signature.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
InsightsScheduler.java Changed cron expression to 0 */5 * * * * for more frequent runs
DashboardService.java Updated method signature, query results parsing, and KPI math
DashboardRepository.java Added findMetricasBasicas and findAlcanceUltimoPost queries
DashboardControllerImpl.java Adjusted null-check and updated call to new service signature
Comments suppressed due to low confidence (6)

src/main/java/com/vulpix/api/service/DashboardService.java:72

  • [nitpick] Changing the signature to accept only a UUID may break existing callers; ensure all consumers are updated or consider providing an overloaded version for backward compatibility.
public DashKpiDto buscaKpisPorPeriodo(UUID empresaId) {

src/main/java/com/vulpix/api/repository/DashboardRepository.java:147

  • [nitpick] Since this query always returns a single row per empresa, you might return an Optional<Object[]> or Object[] directly to make the method contract clearer.
List<Object[]> findMetricasBasicas(@Param("empresa_id") UUID empresaId);

src/main/java/com/vulpix/api/service/DashboardService.java:86

  • Add unit tests covering KPI calculations—particularly for zero-impression scenarios—to ensure both taxaCompartilhamento and taxaSaves behave correctly.
BigDecimal taxaCompartilhamento = totalImpressoes > 0

src/main/java/com/vulpix/api/service/DashboardService.java:87

  • [nitpick] Consider extracting the literal "100" into a named constant (e.g., PERCENT_MULTIPLIER) to clarify its purpose and avoid magic numbers.
new BigDecimal("100").multiply(new BigDecimal(totalShares))

src/main/java/com/vulpix/api/service/integracoes/graph/InsightsScheduler.java:28

  • [nitpick] Running the scheduler every 5 minutes may increase load; consider externalizing this cron expression into configuration or validating that this frequency is intended.
@Scheduled(cron = "0 */5 * * * *")

src/main/java/com/vulpix/api/service/DashboardService.java:99

  • Verify that the order of arguments in this DashKpiDto constructor matches the DTO definition to avoid misaligned KPI values.
return new DashKpiDto(

Copy link
Member

@ezpmartins ezpmartins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@ezpmartins ezpmartins merged commit 1401019 into main Jun 8, 2025
5 of 6 checks passed
@lucas-oristanio lucas-oristanio deleted the fix/get-dash branch June 8, 2025 22:02
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.

3 participants