Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/api/hooks/useAppUsage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ export const useAppUsage = ({ rangeMode, date }: { rangeMode: 'day' | 'week' | '
start = DateTime.fromJSDate(date).startOf('day')
end = DateTime.fromJSDate(date).endOf('day')
} else if (rangeMode === 'week') {
start = DateTime.fromJSDate(date).minus({ days: 6 }).startOf('day')
end = DateTime.fromJSDate(date).endOf('day')
// Get Monday-Sunday of the week containing the selected date
const currentDate = DateTime.fromJSDate(date)
const monday = currentDate.minus({ days: currentDate.weekday - 1 })
start = monday.startOf('day')
end = monday.plus({ days: 6 }).endOf('day') // Sunday
} else {
// Month view - show current week and previous 4 weeks
const currentDate = DateTime.fromJSDate(date)
Expand Down Expand Up @@ -73,8 +76,11 @@ export const useGetChartData = ({ rangeMode, date }: { rangeMode: 'day' | 'week'
start = DateTime.fromJSDate(date).startOf('day')
end = DateTime.fromJSDate(date).endOf('day')
} else if (rangeMode === 'week') {
start = DateTime.fromJSDate(date).minus({ days: 6 }).startOf('day')
end = DateTime.fromJSDate(date).endOf('day')
// Get Monday-Sunday of the week containing the selected date
const currentDate = DateTime.fromJSDate(date)
const monday = currentDate.minus({ days: currentDate.weekday - 1 })
start = monday.startOf('day')
end = monday.plus({ days: 6 }).endOf('day') // Sunday
} else {
// Month view - show current week and previous 4 weeks
const currentDate = DateTime.fromJSDate(date)
Expand Down
19 changes: 15 additions & 4 deletions src/api/monitorApi/monitorApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,22 @@ function aggregateTimeBlocks(
}

return Object.entries(buckets)
.sort(([keyA], [keyB]) => {
Copy link
Member

Choose a reason for hiding this comment

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

can you provide more information about what this change is about? I'm assuming there is a bug?

Copy link
Collaborator Author

@luiskcc luiskcc Nov 5, 2025

Choose a reason for hiding this comment

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

The date keys (e.g., "2025-11-03", "2025-11-04") were coming out in random order. This caused the graph to show days like: Tue, Wed, Mon... etc(wrong order). Adding localeCompare() sorts the ISO date strings alphabetically, which gives us chronological order: Mon... Sun

Copy link
Member

Choose a reason for hiding this comment

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

Are they not currently in order? I haven't seen this issue yet

// Sort by date to ensure correct chronological order
return keyA.localeCompare(keyB)
})
.filter(([key]) => {
if (unit !== 'week') return true
// Only include weeks that have started and are not in the future
const dt = DateTime.fromFormat(key, 'kkkk-WW')
return dt <= DateTime.local().endOf('day')
if (unit === 'day' && start && end) {
// Only include days within the start-end range
const dt = DateTime.fromISO(key)
return dt >= start.startOf('day') && dt <= end.startOf('day')
}
if (unit === 'week') {
// Only include weeks that have started and are not in the future
const dt = DateTime.fromFormat(key, 'kkkk-WW')
return dt <= DateTime.local().endOf('day')
}
return true
})
.map(([key, vals]) => {
let dt: DateTime
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stores/usageSummaryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface UsageSummaryStore {

export const useUsageSummaryStore = create<UsageSummaryStore>((set) => ({
date: new Date(),
rangeMode: 'day',
rangeMode: 'week',
setDate: (date) => set({ date }),
setRangeMode: (rangeMode) => set({ rangeMode }),
}))
2 changes: 1 addition & 1 deletion src/lib/utils/environment.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const isEarlyAccessUser = (email?: string, licenseType?: LicenseType) =>
}

export const isTideGoalsFeatureEnabled = (email?: string, licenseType?: LicenseType) => {
return isEarlyAccessUser(email, licenseType)
return isDev() || isEarlyAccessUser(email, licenseType)
}
15 changes: 11 additions & 4 deletions src/pages/useUsageSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ export function useUsageSummary() {
const getPreviousPeriod = () => {
let prevStart, prevEnd
if (rangeMode === 'week') {
prevStart = DateTime.fromJSDate(date).minus({ days: 13 }).startOf('day')
prevEnd = DateTime.fromJSDate(date).minus({ days: 7 }).endOf('day')
// Get Monday of the previous week
const currentDate = DateTime.fromJSDate(date)
const thisMonday = currentDate.minus({ days: currentDate.weekday - 1 })
const prevMonday = thisMonday.minus({ weeks: 1 })
prevStart = prevMonday.startOf('day')
prevEnd = prevMonday.plus({ days: 6 }).endOf('day') // Sunday
} else {
// Month view - previous 4 weeks before current 4 weeks
const currentDate = DateTime.fromJSDate(date)
Expand All @@ -80,8 +84,11 @@ export function useUsageSummary() {
start = DateTime.fromJSDate(date).startOf('day')
end = DateTime.fromJSDate(date).endOf('day')
} else if (rangeMode === 'week') {
start = DateTime.fromJSDate(date).minus({ days: 6 }).startOf('day')
end = DateTime.fromJSDate(date).endOf('day')
// Get Monday-Sunday of the week containing the selected date
const currentDate = DateTime.fromJSDate(date)
const monday = currentDate.minus({ days: currentDate.weekday - 1 })
start = monday.startOf('day')
end = monday.plus({ days: 6 }).endOf('day') // Sunday
} else {
// Month view - show current week and previous 4 weeks
const currentDate = DateTime.fromJSDate(date)
Expand Down