Skip to content

Commit

Permalink
Revert "fix(UI): incorrect month showing in MAU"
Browse files Browse the repository at this point in the history
This reverts commit a4d95b8.
  • Loading branch information
kevinkarchacryl committed Jan 17, 2025
1 parent 05ed277 commit 7829633
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,8 @@ private TimeSeriesChart getActiveUsersTimeSeriesChart(
final DateTime end,
final String title,
final DateInterval interval) {

final DateRange dateRange;

// adjust month to show 1st of month rather than last day of previous month
if (interval == DateInterval.MONTH) {
dateRange =
new DateRange(
String.valueOf(beginning.plusDays(1).getMillis()), // Shift start by 1 day
String.valueOf(end.plusDays(1).getMillis()) // Shift end by 1 day
);
} else {
// week display starting Sundays
dateRange =
new DateRange(String.valueOf(beginning.getMillis()), String.valueOf(end.getMillis()));
}
final DateRange dateRange =
new DateRange(String.valueOf(beginning.getMillis()), String.valueOf(end.getMillis()));

final List<NamedLine> timeSeriesLines =
_analyticsService.getTimeseriesChart(
Expand All @@ -109,7 +96,6 @@ private TimeSeriesChart getActiveUsersTimeSeriesChart(
ImmutableMap.of(),
Collections.emptyMap(),
Optional.of("browserId"));

return TimeSeriesChart.builder()
.setTitle(title)
.setDateRange(dateRange)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,4 @@ public void testStartOfNextWeek() {
Mockito.when(dateUtil.getNow()).thenReturn(setTimeParts(8, false));
assertEqualStartOfNextWeek(dateUtil, 9);
}

// validates logic to display correct dates in MAU chart
@Test
public void testDateAdjustmentsForMonth() {
DateUtil dateUtil = Mockito.spy(DateUtil.class);

Mockito.when(dateUtil.getNow()).thenReturn(new DateTime(2024, 11, 15, 0, 0, 0));

// start date should be next month minus a day
// but we want to display Dec 1 instead of Nov 30, so add a day and verify it's Dec
DateTime startOfNextMonthMinus12 = dateUtil.getStartOfNextMonth().minusMonths(12);
DateTime adjustedStart = startOfNextMonthMinus12.minusMillis(1).plusDays(1);
assertEquals(12, adjustedStart.getMonthOfYear()); // Verify it is December
assertEquals(2023, adjustedStart.getYear()); // Verify it is 2023

// verify that the end date displays correctly
// the chart will display Oct 1 as the last month because we don't show current month
DateTime startOfThisMonth = dateUtil.getStartOfThisMonth();
DateTime adjustedEnd = startOfThisMonth.minusMillis(1).plusDays(1);
assertEquals(11, adjustedEnd.getMonthOfYear()); // Verify it is November
assertEquals(2024, adjustedEnd.getYear()); // Verify it is 2024
}
}

0 comments on commit 7829633

Please sign in to comment.