Skip to content

Commit abefb77

Browse files
committed
Other PR suggestions
1 parent 015fc0c commit abefb77

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

WordPress/src/main/java/org/wordpress/android/ui/newstats/todaysstat/StatsRepository.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ private const val DAILY_QUANTITY = 1u
2222

2323
// Daily aggregates response field indexes
2424
// Response fields order: period, views, visitors, likes, reblogs, comments, posts
25+
@Suppress("unused") private const val INDEX_PERIOD = 0
2526
private const val INDEX_VIEWS = 1
2627
private const val INDEX_VISITORS = 2
2728
private const val INDEX_LIKES = 3
29+
@Suppress("unused") private const val INDEX_REBLOGS = 4
2830
private const val INDEX_COMMENTS = 5
31+
@Suppress("unused") private const val INDEX_POSTS = 6
2932

3033
/**
3134
* Repository for fetching stats data using the wordpress-rs API.
@@ -124,6 +127,10 @@ class StatsRepository @Inject constructor(
124127
}
125128

126129
val calendar = Calendar.getInstance()
130+
// The API's endDate is exclusive for hourly queries, so we need to add 1 day to get
131+
// the target day's hours. Formula: 1 (for exclusive end) - offsetDays (0=today, 1=yesterday)
132+
// Examples: offsetDays=0 → tomorrow's date → fetches today's hours
133+
// offsetDays=1 → today's date → fetches yesterday's hours
127134
calendar.add(Calendar.DAY_OF_YEAR, 1 - offsetDays)
128135
val dateString = dateFormat.format(calendar.time)
129136

0 commit comments

Comments
 (0)