-
Notifications
You must be signed in to change notification settings - Fork 62
fix(reports): correct date parsing and weekly range calculation #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import React from 'react'; | |
| import { ReportsViewProps } from '../../utils/types'; | ||
| import { getStartOfDay } from '../../utils/utils'; | ||
| import { ReportChart } from './ReportChart'; | ||
| import { parseTaskwarriorDate } from '../Tasks/tasks-utils'; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using shared parseTaskwarriorDate utility |
||
|
|
||
| export const ReportsView: React.FC<ReportsViewProps> = ({ tasks }) => { | ||
| const now = new Date(); | ||
|
|
@@ -16,10 +17,13 @@ export const ReportsView: React.FC<ReportsViewProps> = ({ tasks }) => { | |
| const countStatuses = (filterDate: Date) => { | ||
| return tasks | ||
| .filter((task) => { | ||
| const taskDateStr = task.modified || task.due; | ||
| const taskDateStr = task.end || task.due || task.entry; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. completed tasks now use end date for filtering and entry as fallback for pending tasks without a due date |
||
| if (!taskDateStr) return false; | ||
|
|
||
| const modifiedDate = getStartOfDay(new Date(taskDateStr)); | ||
| const parsedDate = parseTaskwarriorDate(taskDateStr); | ||
| if (!parsedDate) return false; | ||
|
|
||
| const modifiedDate = getStartOfDay(parsedDate); | ||
| return modifiedDate >= filterDate; | ||
| }) | ||
| .reduce( | ||
|
|
@@ -36,9 +40,7 @@ export const ReportsView: React.FC<ReportsViewProps> = ({ tasks }) => { | |
| }; | ||
|
|
||
| const dailyData = [{ name: 'Today', ...countStatuses(today) }]; | ||
| const sevenDaysAgo = getStartOfDay(new Date()); | ||
| sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7); | ||
| const weeklyData = [{ name: 'This Week', ...countStatuses(sevenDaysAgo) }]; | ||
| const weeklyData = [{ name: 'This Week', ...countStatuses(startOfWeek) }]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed weekly report to use startOfWeek, now this ensures "This Week" actually represents the current calendar week, not just the last 7 days |
||
| const monthlyData = [{ name: 'This Month', ...countStatuses(startOfMonth) }]; | ||
|
|
||
| return ( | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refactored isOverdue to use the shared parseTaskwarriorDate utility |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated mock task data to use valid dates |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated dates, test names, and fallbacks |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added tests for parseTaskwarriorDate function |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. centralized Taskwarrior date parsing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
show values above bars and removed cursor highlight effect (for better UX)