Skip to content
Open
4 changes: 2 additions & 2 deletions api/resources/translations/messages-en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1248,8 +1248,8 @@ targets.births.title = Births
targets.count.default = ({{pass}} of {{total}})
targets.disabled = Targets are disabled for your user account.
targets.no_targets = No target found.
targets.this_month.subtitle = This month
targets.last_month.subtitle = Last month
targets.this_month.subtitle = Current month
targets.last_month.subtitle = Previous month
task.date = Due date
task.days.left = {DAYS, plural, one{1 day left} other{\# days left}}
task.list.complete = No more tasks
Expand Down
2 changes: 1 addition & 1 deletion api/src/public/login/lib-bowser.js

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion webapp/src/ts/modules/analytics/analytics-targets.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,20 @@
<h2 *ngIf="target.translation_key">{{ target.translation_key | translate }}</h2>
<h2 *ngIf="!target.translation_key">{{ target.name | translateFrom }}</h2>
<p *ngIf="target.subtitle_translation_key">
{{ target.subtitle_translation_key | translate }}

<!-- 🔹 Show “Current month” when current filter is selected -->
<ng-container *ngIf="reportingPeriodFilter === 'current'; else previousSubtitle">
{{ 'targets.this_month.subtitle' | translate }}
</ng-container>

<!-- 🔹 Show “All time” when previous month is selected -->
<ng-template #previousSubtitle>
{{ 'targets.all_time.subtitle' | translate }}
<!-- Inline note: only show when previous period -->

</ng-template>


Copy link
Contributor

Choose a reason for hiding this comment

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

Lets roll this back for now and wait for #10439 to make any changes to the UI.

Suggested change
<!-- 🔹 Show “Current month” when current filter is selected -->
<ng-container *ngIf="reportingPeriodFilter === 'current'; else previousSubtitle">
{{ 'targets.this_month.subtitle' | translate }}
</ng-container>
<!-- 🔹 Show “All time” when previous month is selected -->
<ng-template #previousSubtitle>
{{ 'targets.all_time.subtitle' | translate }}
<!-- Inline note: only show when previous period -->
</ng-template>
{{ target.subtitle_translation_key | translate }}

Copy link
Author

Choose a reason for hiding this comment

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

Due to the label being static, The filtering does the sorting by date but leaves the labels constant. So when you click this month or last month the labels remain constant. So we decided to change the label according to what has been chosen . Though now differently as indicated in the new PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed at the squad meeting this week, we want to go ahead and leave this html as it is for now. We are continuing to discuss what the best approach will be for the UI changes. These will be implemented in r #10439.

Copy link
Author

Choose a reason for hiding this comment

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

Am changing it first think tomorrow. Just got abit engaged.

</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class AnalyticsTargetsComponent implements OnInit, OnDestroy {
.isEnabled()
.then(isEnabled => {
this.targetsDisabled = !isEnabled;
return isEnabled ? this.rulesEngineService.fetchTargets() : [];
return isEnabled ? this.rulesEngineService.fetchTargets(this.reportingPeriodFilter) : [];
})
.catch(err => {
console.error('Error getting targets', err);
Expand Down
12 changes: 12 additions & 0 deletions webapp/src/ts/services/calendar-interval.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ export class CalendarIntervalService {
getInterval(startDate:number, timestamp:number) {
return CalendarInterval.getInterval(startDate, timestamp);
}

/**
* Returns the previous reporting period interval based on the start day.
* This is used when the sidebar filter selects "previous month".
*/
getPrevious(startDate: number) {
const now = Date.now();
const previousMonth = new Date(now);
previousMonth.setMonth(previousMonth.getMonth() - 1);
return CalendarInterval.getInterval(startDate, previousMonth.valueOf());
}

}
7 changes: 3 additions & 4 deletions webapp/src/ts/services/rules-engine.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,12 @@ export class RulesEngineService implements OnDestroy {
let trackPerformanceRunning;

await this.initialized;
this.telemetryService.record(
'rules-engine:targets:dirty-contacts',
this.rulesEngineCore.getDirtyContacts().length
);
this.telemetryService.record('rules-engine:targets:dirty-contacts', this.rulesEngineCore.getDirtyContacts().length);
this.cancelDebounce(this.FRESHNESS_KEY);
await this.waitForDebounce(this.CHANGE_WATCHER_KEY);

const relevantInterval = this.calendarIntervalService.getCurrent(this.uhcMonthStartDate);

const targets = await this.rulesEngineCore
.fetchTargets(relevantInterval)
.on('queued', () => trackPerformanceQueueing = this.performanceService.track())
Expand All @@ -516,6 +514,7 @@ export class RulesEngineService implements OnDestroy {
trackPerformanceRunning = this.performanceService.track();
}
trackPerformanceRunning?.stop({ name: trackName });

return targets;
}

Expand Down
Loading